I have a Content tree in Umbraco where I have 3 main pages with their subpages. I also have 5 other pages that are child of Homepage which they have 2 options set: umbIsChildOfHomePage = 1 and umbracoNaviHide = 1
Take a look at structure:

Now: I want to generate a umb2ndLevelNavigation for each page.
I have this in my xslt file
<xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
<xsl:if test="count($items) > 0">
<ul>
<xsl:for-each select="$items">
<li>
<xsl:if test="position() = last()">
<xsl:attribute name="class">last</xsl:attribute>
</xsl:if>
<xsl:if test="position() = 1">
<xsl:attribute name="class">first</xsl:attribute>
</xsl:if>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
which will work only for pages other than homepage.
So need to extra personalize xslt select. How do I do that?
This is what I tried. I appended it to the template because I dont’t know how to append the condition in other select.
<xsl:variable name="itemsHomepage" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 1]/* [@isDoc and string(umbracoNaviHide) = '1' and string(umbIsChildOfHomePage) = 1]"/>
<xsl:if test="count($itemsHomepage) > 0">
<ul>
<!--<xsl:attribute name="class">
a<xsl:value-of select="$currentPage/parent::*[@isDoc]/@id [string(umbIsChildOfHomePage) = 1 ]" />
</xsl:attribute>-->
<xsl:for-each select="$itemsHomepage">
<li>
<xsl:if test="position() = last()">
<xsl:attribute name="class">last</xsl:attribute>
</xsl:if>
<xsl:if test="position() = 1">
<xsl:attribute name="class">first</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="name() = 'Link'">
<a href="{current()/linkUrl}" target="_blank">
<xsl:value-of select="@nodeName" />
</a>
</xsl:when>
<xsl:otherwise>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</a>
</xsl:otherwise>
</xsl:choose>
</li>
</xsl:for-each>
<!--<li>
s:<xsl:value-of select="$currentPage/@id" />
<xsl:value-of select="$RootNode/@nodeName"/>-<xsl:value-of select="$RootNode/@id"/>
</li>-->
</ul>
</xsl:if>
The issue is that even if I go to a page that does not have childs items of homepage will be shown even for a page that does not have childs.
How do I personalize the select to show only when a page that have those 2 parameters(showNavi, and isHomePageChild) set on true?
Thanks for your help.
Hope you understood the issue.
The initial code is targeting the nodes from the top down to level ‘2’ – which sounds correct for what you want, you just need to get it to render out
There’s a good example here of what you are trying to do.
Stripped that solution down ($level is set to 2) reminds me why I won’t go near xslt again willingly!:
and so on…