Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 02, 2011 @ 09:10
    Fuji Kusaka
    0

    SiteMap XSLT

    Hi Guys,

     

    I have some issues with displaying some of the nodes in my site map. Actually i have some nodes which are hidden in my Navigation and so making use of the umbraco Property umbracoNaviHide, but I managed to make those links visible in my sitemap.

    However I have some nodes in a folder in my content root which needs to be visible in the sitemap. Here is the piece of code am using with the following structure

    <xsl:variable name="maxLevelForSitemap" select="4"/>

    <xsl:template match="/">
    <div class="siteText">
      <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"/>
      <!-- Testing for protection -->
      <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="sitemap"
      <xsl:for-each select="$parent/* [@isDoc and @level &lt;= $maxLevelForSitemap]">
    <li
     
      
      <a 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>

     

    - Content

    -- Default

    --- Page 1

    ---- Sub Page 1

    ---- Sub Page 2

    ---- Sub Page 3

    --- Page 2

    ---- Sub Page 1

    ---- Sub Page 2

    --- Page 3

    -- Folder 1

    --- Page 1

    ---- Sub Page 1

    ---- Sub Page 2

    ---- Sub Page 3

     

    At the moment i can see the nodes of Folder 1 in my sitemap. Can someone suggest something?

     

    //fuji

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 02, 2011 @ 15:08
    Tom Fulton
    0

    Hi Fuji,

    If I understand you are only seeing one of the trees?  Either Default or Folder 1?

    The issue is probably that your starting xpath query is starting at the first level 1 ancestor, when you should start at the content root if you want all level 1 nodes.  Try this instead:

    <xsl:call-template name="drawNodes">  
     <xsl:with-param name="parent" select="$currentPage/ancestor::root/* [@isDoc and @level=1]"/> 
    </xsl:call-template>

    Hope this helps,
    -Tom

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 02, 2011 @ 19:42
    Fuji Kusaka
    0

    Hi Tom,

     

    Yes am only seeing the nodes from Default while what i want is to be able to view bothe Default and Folder 1.

    But i do have some other folder in my tree not only Default and Folder 1. My question is how to i get my sitemap to display all nodes under Default and Folder 1 and not to display the nodes from lets say Folder 2 - Folder 5.

     

    //Fuji

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 02, 2011 @ 20:03
    Tom Fulton
    0

    Well, since all the nodes are on the same level I think you need a way to distinguish them from each other.  Perhaps an umbracoNaviHide property or a new property "Hide in Sitemap"?

    You could then do

    <xsl:call-template name="drawNodes">  
     
    <xsl:with-param name="parent" select="$currentPage/ancestor::root/* [@isDoc and @level=1 and string(umbracoNaviHide) != '1']"/>  
    </xsl:call-template>

    Another option would be to start at the content root and only use the first two nodes (Default and Folder1) - assuming they'd always be in that order?

    <xsl:call-template name="drawNodes">  
     
    <xsl:with-param name="parent" select="$currentPage/ancestor::root/* [@isDoc and @level=1][position() &lt; 3]"/>  
    </xsl:call-template>

    -Tom

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 02, 2011 @ 21:06
    Fuji Kusaka
    0

    Actually i removed the umbracoNaviHide since i want to show the hidden links in the sitemap. But will try your suggesiton.

     

    fuji

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 03, 2011 @ 11:42
    Fuji Kusaka
    0

    Tom it works, thanks mate.

     

    //fuji

  • Gus Deadman 45 posts 65 karma points
    Jun 11, 2012 @ 16:36
    Gus Deadman
    0

    I tried both "call-template" suggestions and they both crashed IIS. Not sure how but it did everytime.

    My workaround was to use the custom property in a different way. I used it to exclude the Site Map itself from the listing on the Site Map page by creating a custom property called (as suggested) hideinSiteMap in the Site Map Document Type and adding a new criterion “and string(hideinSitemap) != '1' ” to the criteria in the XSL “for-each select” statement in the standard Site Map XSLT. I've no idea if this is the best way but the effect was to exclude the chosen page. I also did this for the root of a sub-section of the site and it and the child pages were excluded. So far I haven't discovered any negative effects.

     

     

Please Sign in or register to post replies

Write your reply to:

Draft