使用XSLT为umbraco创建多级菜单?

时间:2010-11-04 17:00:16

标签: xslt umbraco

如何使用XSLT创建这样的Umbraco菜单?

<ul id="topmenu">
     <li><a href="#">top1</a></li>
     <li><a href="#">top2</a></li>
     <li><a href="#">top3</a>
         <ul>
         <li><a href="#">sub1</a></li>
         <li><a href="#">sub2</a></li>
         <li><a href="#">sub3</a></li>
         </ul>
      </li>
      <li><a href="#">top4</a></li>
      <li><a href="#">top5</a></li>
 </ul>menu like this using XSLT ? 

1 个答案:

答案 0 :(得分:7)

这样的事情应该有效。这基于最初生成的Navigation XSLT。

<ul class="nav sf-menu">
<xsl:for-each select="$currentPage/ancestor-or-self::*[@isDoc and @level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">

  <li>

    <a href="{umbraco.library:NiceUrl(@id)}">
      <xsl:value-of select="@nodeName"/>
    </a>
    <xsl:if test="count(./child::*[@isDoc and string(umbracoNaviHide) != '1']) &gt; 0">
      <ul>
        <xsl:for-each select="./child::*[@isDoc and string(umbracoNaviHide) != '1']">
          <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
              <xsl:value-of select="@nodeName"/>
            </a>
          </li>
        </xsl:for-each>
      </ul>  
    </xsl:if>
  </li>


</xsl:for-each>
</ul>