Javascript code appears in Recent Blog Posts content item

Topics: Troubleshooting
Jul 23, 2013 at 4:33 AM
In the Recent Blog Posts content item, some Javascript code for my Google Map appears before the "more" link in the "Location" post. However, this text does not appear in the full post. How can I remove the code from the Recent Blog Posts item?
Jul 25, 2013 at 8:25 PM
Edited Jul 25, 2013 at 8:25 PM
Just checking in to see if anyone has any idea how to fix the problem I described in my post.
Coordinator
Jul 25, 2013 at 8:27 PM
Where does that Google Map code code from? Did you include that in the body of that post?
Jul 25, 2013 at 8:51 PM
Yes, all the code is in the body of the blog post. See the code below.
<p>
The Solar Decathlon China competition is located in <a href="https://en.wikipedia.org/wiki/Datong" target="_blank" title="Wikipedia page">Datong</a>, a <a href="https://en.wikipedia.org/wiki/Prefecture-level_city" target="_blank" title="Wikipedia page">prefecture-level city</a> in the northern Shanxi province of the People&#39;s Republic of China.
</p>

<script src="https://maps.googleapis.com/maps/api/js?key=[KEY REMOVED FOR SECURITY]&sensor=false"></script><script>
      function initialize() {
        var mapOptions = {
          center: new google.maps.LatLng(40.091402, 113.359591),
          zoom: 11,
          mapTypeId: google.maps.MapTypeId.HYBRID
        };
        var map = new google.maps.Map(document.getElementById("map-canvas"),
            mapOptions);
      }
      google.maps.event.addDomListener(window, 'load', initialize);
</script>

<div id="map-canvas" style="height: 500px">&nbsp;</div>
Coordinator
Jul 25, 2013 at 9:04 PM
Putting script in body is not good practice, but if you must, you can alter the way the summary is rendered: http://weblogs.asp.net/bleroy/archive/2012/07/01/my-body-summary-template-for-orchard.aspx
Jul 25, 2013 at 9:12 PM
Thank you very much, Bertrand. I'm including script in the body as a stopgap measure until I better understand and have the time to implement best practices. What is the best practice for this kind of script? Should it go inside my theme's Scripts folder?
Coordinator
Jul 26, 2013 at 12:00 AM
It depends what you are trying to do.
Jul 26, 2013 at 5:07 AM
Edited Jul 26, 2013 at 5:07 AM
In the near term, I'm going to be creating a lot of blog posts that will include one-off content using various Javascript and jQuery APIs, such as Google Maps, amCharts, FullCalendar, HotspotMap, etc. What is the recommended approach for including such one-off content in Orchard blogs, assuming that I'm not currently too worried about code duplication or other best practices?
Coordinator
Jul 27, 2013 at 6:08 AM
If it's one-off (which is weird), then yes, put it in the body.