Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I can get the parent node name on a specific level by using
$currentPage/ancestor::node [@level=1]/node/@nodeName
But this gets all the nodes on this level. Is there an elegant way to select just the "level 1 parent" of $currentPage?
Your xslt gets the names of the children of the level 1 node. Not the name of the level 1 node.
try
$currentPage/ancestor::node [@level=1]/@nodeName
ah... that's it! Time to knock off work :)
Sorry to bump this thread after 11 months, but I found it really useful!
But following on from this, how could I turn this into a link to the level 1 node it's just found?
Thanks,
Tom
Depends slightly on the version your running?
in 4.5 this works in my testing:
<a href="{umbraco.library:NiceUrl($currentPage/ancestor::* [@level=1]/@id)}"><xsl:value-of select="$currentPage/ancestor::* [@level=1]/@nodeName"/></a>
A word of caution: Because NiceUrl is expecting an integer, you'll have to check the "Skip Testing" in order to save the XSLT.
I haven't learned how to avoid that yet!
Hi Dave,
Thanks for that, but it's actually whatever the level 2 node it's sitting in that I want it to show.
If I use your code and change the 1 to a 2, it comes up with:Error parsing XSLT file: \xslt\leftnav.xslt
I'm using version: umbraco v 4.0.4.2 (Assembly version: 1.0.3811.17115), by the way..
Can anyone help? :(
In order to avoid the error, test for an empty value first.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to get the parent node name on a specific level from current page
I can get the parent node name on a specific level by using
$currentPage/ancestor::node [@level=1]/node/@nodeName
But this gets all the nodes on this level. Is there an elegant way to select just the "level 1 parent" of $currentPage?
Your xslt gets the names of the children of the level 1 node. Not the name of the level 1 node.
try
ah... that's it! Time to knock off work :)
Sorry to bump this thread after 11 months, but I found it really useful!
But following on from this, how could I turn this into a link to the level 1 node it's just found?
Thanks,
Tom
Depends slightly on the version your running?
in 4.5 this works in my testing:
A word of caution: Because NiceUrl is expecting an integer, you'll have to check the "Skip Testing" in order to save the XSLT.
I haven't learned how to avoid that yet!
Hi Dave,
Thanks for that, but it's actually whatever the level 2 node it's sitting in that I want it to show.
If I use your code and change the 1 to a 2, it comes up with:
Error parsing XSLT file: \xslt\leftnav.xslt
I'm using version: umbraco v 4.0.4.2 (Assembly version: 1.0.3811.17115), by the way..
Can anyone help? :(
Thanks,
Tom
In order to avoid the error, test for an empty value first.
is working on a reply...