Copied to clipboard

Flag this post as spam?

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


  • Kevin 6 posts 26 karma points
    Dec 26, 2011 @ 22:43
    Kevin
    0

    Get sitemap to include homepage node

    Hello,

    I have a runway sitemap and I would like to include the homepage node in the following structure:

    Content
    --Frontpage (homepage)
    ----Subpage1
    ----Subpage2
    --------SubSubpage1
    --------SubSubpage2
    ----Subpage3

    Any  help accomplishing this would be great. The sitemap displays everything except the frontpage (homepage) node. 

    Here is my XSLT code:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet 
      version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:msxml="urn:schemas-microsoft-com:xslt" 
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" 
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <!-- update this variable on how deep your site map should be -->
    <xsl:variable name="maxLevelForSitemap" select="4"/>
    <xsl:template match="/">
    <div id="top-nav"
    <xsl:call-template name="drawNodes">  
    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]"/>  
    </xsl:call-template>
    </div>
    </xsl:template>
    <xsl:template name="drawNodes">
    <xsl:param name="parent"/> 
    <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
    <ul class="sf-menu"
    <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevelForSitemap]"
    <li>  
    <href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName"/></a>  
    <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevelForSitemap]) &gt; 0">   
    <xsl:call-template name="drawNodes">    
    <xsl:with-param name="parent" select="."/>    
    </xsl:call-template>  
    </xsl:if
    </li>
    </xsl:for-each>
    </ul>
    </xsl:if>
    </xsl:template>
    </xsl:stylesheet>
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 27, 2011 @ 08:29
    Jan Skovgaard
    0

    Hi Kevin

    You can simply just add the link to the frontpage by hardcoding it before the for-each statement so you insert <li><a href="/">Frontpage</a></li> right after <ul class="sf-menu">.

    Hope this helps.

    /Jan

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Dec 27, 2011 @ 10:22
    Dirk De Grave
    0

    I wouldn't do that, think you'll get duplicate items as it's a recursive template... so should include it before the first call to drawNodes, ie after the 

    <div id="top-nav">

     

    Cheers,

    /Dirk

  • Eddie Foreman 215 posts 288 karma points
    Dec 30, 2011 @ 12:38
    Eddie Foreman
    0

    Hi Kevin,

    Using the Umbraco sitemap xslt.  I add an if statement just before the foreach in the drawnodes template to add in the home page link.

    <ul class="sitemap">
    <xsl:if test="$parent/@level = 1">
    <li>
                <a href="/">Home</a>
    </li>
    </xsl:if>
    <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevelForSitemap]"> 

    Thanks,
    Eddie

  • Mike 81 posts 101 karma points
    Jan 11, 2012 @ 21:13
    Mike
    0

    I was just struggling with this.. my issue was that I was using @currentpage!!!

  • 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