New to Umbraco and xslt, I’ve got a problem with the menu of my first Umbraco website.
When displaying a parent page (node), the 2nd level menu is working fine and displaying its children. However, when displaying one of its children pages, the 2nd level menu is not displaying the page and the others with same parent.
There are some document types I don’t want to display in the menu and it looks like my problem is due to my poor attempt to filter the document types (displaying only “umbTextpage” and “PageTwoColumns”) :
<xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
<xsl:if test="$currentPage/umbTextpage or $currentPage/PageTwoColumns">
<!-- Find the top node for the subnav -->
<xsl:variable name="currentSection" select="ancestor-or-self::*[@level = 2]" />
<!-- Select the items you want to show off of currentSection -->
<xsl:variable name="items" select="$currentSection/*[self::umbTextpage or self::PageTwoColumns][not(umbracoNaviHide = 1)]" />
<!-- If that set has any nodes ... -->
<xsl:if test="$items">
<ul id="subNavigation">
<xsl:for-each select="$items">
<li>
<a class="navigation" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
Using a couple extra variables can make it much easier to read and understand where to put changes etc.
2nd level menu : filtering document types problem
New to Umbraco and xslt, I’ve got a problem with the menu of my first Umbraco website.
When displaying a parent page (node), the 2nd level menu is working fine and displaying its children. However, when displaying one of its children pages, the 2nd level menu is not displaying the page and the others with same parent.
There are some document types I don’t want to display in the menu and it looks like my problem is due to my poor attempt to filter the document types (displaying only “umbTextpage” and “PageTwoColumns”) :
<xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
<xsl:if test="$currentPage/umbTextpage or $currentPage/PageTwoColumns">
<xsl:if test="count($items) > 0">
<ul id="subNavigation">
<xsl:for-each select="$items">
<li>
<a class="navigation" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:if>
Any help, please ?
Hi Evelyne,
Try this approach:
Using a couple extra variables can make it much easier to read and understand where to put changes etc.
/Chriztian
Hi Chriztian,
Thank you for your reply.
Unfortunately, it doesn't work. Even in parent page, this xslt don't return any result...
Thank you,
Evelyne
Hi Evelyne,
Sorry about that - I forgot to base everything off $currentPage - if you add in the very first line, you should see some results, e.g.:
/Chriztian
Yes, it's working !
Thank you very much, Chriztian
is working on a reply...