Copied to clipboard

Flag this post as spam?

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


  • Simon 10 posts 30 karma points
    Nov 16, 2010 @ 13:25
    Simon
    0

    Creating a sitemap - multiple root levels

    I need to make a slightly different style sitemap. Basically the site structure is this:

     

    • HomePage
    • Sitemap
    • Terms
    • Men
      • Page 1
      • Page 2
    • Women
      • Page 1
      • Page 2

    This was a requirement, hence everything is not under the "homepage" page.

    There could be more than the two levels, so would like it to be recursive.

    Basically all I want is some xslt to do this

    FOR EACH ROOT NODE

          Display Node(Root)

    NEXT

     

    Display Node(Root)

    <li>
    <a href=NiceUrl()><h2>Node Name</h2></a>

    FOR EACH ChildNode

    Display node(child)

    NEXT

    </li>

     

    I can work out the child node part, but really strugling to find something to get all root nodes

    ancestor-or-self only seems to return a single top level node...

    Thanks in advance!

     

  • Simon 10 posts 30 karma points
    Nov 16, 2010 @ 13:26
    Simon
    0

    Had an error editing this post (xslt error, it really is out to get me...)

    This is for Umbraco 4.5 :-)

  • Rich Green 2246 posts 4008 karma points
    Nov 16, 2010 @ 13:47
    Rich Green
    0

    I'm not sure I would like to code a website with that structure, maybe will cause more trouble than it's worth.

     However if that is how it has to stay, you should be able to work from the root node, like this

    <!--Get root of site regardless of where you are in site)-->
    <xsl:variable name="absoluteRoot" select="$currentPage/ancestor-or-self::root" />

     

    Rich

  • Simon 10 posts 30 karma points
    Nov 16, 2010 @ 14:13
    Simon
    0

    Will this return the set of nodes, so will be able to loop through? all the root pages?

  • Rich Green 2246 posts 4008 karma points
    Nov 16, 2010 @ 16:10
    Rich Green
    0

    Hi Simon,

    Use the standard Umbraco SiteMap XSLT and change the following line

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

    to

    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::root/*"/>  

    Not sure I understand what you're trying to do 100% so let me know if this works.

    On a side note - I'd be interested to know why you have had to structure the site in the way you have.

    Rich

  • Simon 10 posts 30 karma points
    Nov 23, 2010 @ 13:35
    Simon
    0

    I would love to know too! I just was given the specification and that's what they wanted. The "root" thing was the missing link and although i'd solved this another way, it helped in another change that was asked!

    Is there a way to see the XML that the XSLT is actually using? It seems a bit black magic as to what you get and what xsl to write.

    Many thanks

  • Bruce Clark 56 posts 80 karma points
    Nov 23, 2010 @ 18:50
    Bruce Clark
    0

    What was the other way you used to solve it out of curiosity?

  • Rich Green 2246 posts 4008 karma points
    Nov 23, 2010 @ 18:52
    Rich Green
    0

    Simon,

    You can view the xml by going to App_Data and opening the umbraco.config file.

    It's definitely a great learning tool.

    Glad you got it sorted

    Rich

     

Please Sign in or register to post replies

Write your reply to:

Draft