Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rik Helsen 670 posts 873 karma points
    Feb 10, 2010 @ 11:21
    Rik Helsen
    0

    Have an XSLT macro output partially in the header, and partially in the content area (GoogleMap)

    I'd like to create a single XSLT macro that i can use throughout content area's, to include google maps with lots of pointers (different locations) and different icons.

    The issue i'm looking at is that i need the xslt to:

    * output javascript in the header
    * and a div in the content area where i want to display the map

    Any advice on how to achive this, if it's possible?

    Using a different template would ofcourse also work, but that would limit me as i would have to create a seperate template & document type for each situation where i'd want to use a google map...

    Kind regards,
    Rik

  • dandrayne 1138 posts 2262 karma points
    Feb 10, 2010 @ 11:34
    dandrayne
    0

    You can use umbraco.library:RegisterJavacriptFile (with runat=server on your head tag) to add a stylesheet, but there's usually no need to insert the js in the head of the file as the xslt can simply output javascript in-page with no issues.  In fact speed recommendations often point to this as a way to improve speed on page (move script files towards bottom of page).

    The div in the content area is the trivial part.

    Here's an example of scripts inside xslt, and passing xslt variables to javascript variables.

    <div id="Map" style="width: 630px; height: 200px; border: solid 1px black;margin: 20px 0px;display:none;" >&#160;</div>
    <script type="text/javascript">
    //<![CDATA[
    var postCode = "]]><xsl:value-of select="$postcode" /><![CDATA[";
    var radius = "]]><xsl:value-of select="$currentPage/ancestor-or-self::node[@nodeTypeAlias='Homepage']/data[@alias='deliveryRadius']" /><![CDATA[";
    GenerateMap(postCode, radius);
    //]]>
    </script>

    dsa

  • Rik Helsen 670 posts 873 karma points
    Feb 11, 2010 @ 17:32
    Rik Helsen
    0

    grmbl... xslt doesn't validate the google map code...

  • dandrayne 1138 posts 2262 karma points
    Feb 11, 2010 @ 17:37
    dandrayne
    0

    Post your xslt file here and I can take a look.  It might be as simple as changing & to &amp;

     

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Feb 11, 2010 @ 17:38
    Nik Wahlberg
    1

    Here's an off-the-wall thought. Couldn't you create template regions in your master template and then use UCs to populate them on demand? 

    Just my 2-cents.

    Cheers,
    Nik

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies