我有一個Umbraco中的內容樹,我有3個主頁與他們的子頁面。我也有5個是首頁的孩子,他們有2個選項設置其他網頁:umbIsChildOfHomePage = 1和umbracoNaviHide = 1 看看結構: Xslt選擇條件,如何生成2ndLevelNavigation?
現在:我要爲每一個頁面umb2ndLevelNavigation。
我有這個在我的XSLT文件
<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>
這隻會工作比主頁的其他頁面。 因此需要額外的個性化xslt 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>
問題是,即使我去了一個沒有孩子的網頁的網頁,即使是沒有孩子的網頁也會顯示。 如何使選擇個性化,以便僅當具有2個參數(showNavi和isHomePageChild)的頁面設置爲true時才顯示? 感謝您的幫助。 希望你理解這個問題。