I wanted to use the same topnavigation macro to show different level nodes depending on which branch the user is on. More specifically : if the user is on a page under node @id 1070 he/she should see topnavigation from level 2, otherwise from level 1.
I came up with the following xslt which works, but I wonder if it could be done in a better way?
<xsl:variable name="level"> <xsl:choose> <!-- if we are under member pages the top navigation should show level 2 --> <xsl:when test="count($currentPage/ancestor-or-self::node[@id = 1070])=1"> 2 </xsl:when> <xsl:otherwise> 1 </xsl:otherwise> </xsl:choose> </xsl:variable>
Select topnavigation level depending on branch
I wanted to use the same topnavigation macro to show different level nodes depending on which branch the user is on. More specifically : if the user is on a page under node @id 1070 he/she should see topnavigation from level 2, otherwise from level 1.
I came up with the following xslt which works, but I wonder if it could be done in a better way?
Hi Jonas,
Looks fine for me, the only thing I would not do is put IDs of a page hardcoded inside XSLT.
I think it would be better to add another variable, which can be set through a macro property.
But basically, I think your solution should work just fine.
I think it's even possible to remove the count() function and only have:
(altho have no stats to backup that this solution would be faster)
Second Len's solution, you should not hard code the id
Cheers,
/Dirk
Ok, thanks!
Jonas
is working on a reply...