Copied to clipboard

Flag this post as spam?

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


  • joenne 2 posts 21 karma points
    Jan 19, 2009 @ 10:33
    joenne
    0

    When no children ... show pages at same level

    Hi,

    I'm new to XSLT and have only begun scratching the surface of XSLT and XPath :)


    I have a navigation bar which is supposed to list all children to a current page. However, when no child pages exists, the navigation bar should list the pages which are at the same level as the current page being displayed.

    My current code looks like this:
    [code]

















    [/code]

    Hope for some help ... as I'm pretty stuck.

    Regards, Jens

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Jan 19, 2009 @ 11:38
    Warren Buckley
    0

    Looking at your XSLT quickly, I would say that your XSL:if statements look great and should be working fine.

    The xsl:for-each in the sencond xsl:if (when you have no child nodes) looks a bit odd. If you can tell me what nodes you want to select I can try and help you more.

    Warren

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Jan 19, 2009 @ 11:42
    Warren Buckley
    0

    in you for-each try this xPath statement.

    $currentPage/parent::node/node

    This will select the parent node from the currentPage level (so goes up one folder/level), then looks for all child nodes from that single level.

    Hope that helps.
    I highly recommend this XSLT umbraco book - [url]http://www.umbraco.org/documentation/books/xslt-basics/xpath-axes-and-their-shortcuts[/url]

    Warren

  • joenne 2 posts 21 karma points
    Jan 19, 2009 @ 11:52
    joenne
    0

    That did the job! Thank you very much, Warren :)

    I have tried $currentPage/parent::node but that did not work.

    What is the difference between parent:node/node and parent::node?

    Regards, Jens

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 19, 2009 @ 14:13
    Dirk De Grave
    0

    Hi Jens,

    parent:node/node will select all direct child nodes of the parent node
    parent:node selects only the parent node of the current node

    As Warren's outlined before, have a look at the book in the documentation section, it's a great reference for xpath axis.

    Regards,
    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft