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.
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.
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]
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
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
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
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
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
is working on a reply...