我的菜单模板如下:
<nav class="col-md-12" data-responsive-menu="true" data-responsive-levels="">
<ul class="col-md-12" id="sublist">
[*>NODE-TOP]
</ul>
</nav>
[>NODE-TOP]
[?ENABLED]
<a href="[=URL]" id="sidemenuitem" [?TARGET]target="[=TARGET]" [/?]><li class="subitem">[=TEXT]</li></a>
[?ELSE]
<a href="#" id="sidemenuitem"><li class="subitem">[=TEXT]</li></a>
[/?]
[/>]
这将显示当前页面的子项,如果您单击其中一个子项,它将显示该页面的兄弟。
现在我想向孩子们展示它是否有任何东西,否则它应该展示给它们的兄弟姐妹。
我该如何做到这一点?
答案 0 :(得分:0)
我不确定你的意思。但我使用下面的代码生成带子菜单的菜单树。
<nav class="menuBalk">
[*>NODE-TOP]
</nav>
[>NODE-TOP]
<div class="topMenu[?FIRST] first[/?][?LAST] last[/?][?SELECTED] active[/?]">
[?ENABLED]
<a href="[=URL]" [?TARGET]target="[=TARGET]" [/?]>[=TEXT]</a>
[?ELSE]
<a href="#">[=TEXT]</a>
[/?]
[?NODE]
<span class="subMenuBalk">
[*>NODE]
</span>
[/?]
</div>
[/>]
[>NODE]
<div class="subMenu[?FIRST] first[/?][?LAST] last[/?][?SELECTED] active[/?]">
[?ENABLED]
<a href="[=URL]" [?TARGET]target="[=TARGET]" [/?]>[=TEXT]</a>
[?ELSE]
<a href="#">[=TEXT]</a>
[/?]
[?NODE]
<ul class="subSubMenuBalk">
[*>NODE]
</ul>
[/?]
</div>
[/>]
答案 1 :(得分:0)
我在以下帮助下找到了答案: http://demo.40fingers.net/dnn-ddr-demo-skin/
我为它添加了以下xslt脚本:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:param name="ControlID" />
<xsl:param name="Options" />
<xsl:template match="/*">
<xsl:apply-templates select="root" />
</xsl:template>
<xsl:template match="root">
<nav class="col-md-12" data-responsive-menu="true" data-responsive-levels="">
<ul class="Root" id="sublist">
<xsl:apply-templates select="node">
<xsl:with-param name="level" select="0"/>
<xsl:with-param name="NoChildren">
<xsl:call-template name="NoChildren"/>
</xsl:with-param>
</xsl:apply-templates>
</ul>
</nav>
</xsl:template>
<xsl:template match="node">
<xsl:param name="level" />
<xsl:param name="NoChildren" />
<xsl:choose>
<xsl:when test="$NoChildren='true'">
<!-- Render Siblings as Active page does not have Children-->
<a id="sidemenuitem" href="{@url}">
<xsl:choose>
<xsl:when test="@breadcrumb = 1 and @selected = 1">
<li class="subitem active">
<span>
<xsl:value-of select="@text" />
</span>
</li>
</xsl:when>
<xsl:otherwise>
<li class="subitem">
<span>
<xsl:value-of select="@text" />
</span>
</li>
</xsl:otherwise>
</xsl:choose>
</a>
</xsl:when>
<xsl:otherwise>
<!-- Render Children of Active page-->
<xsl:if test="@breadcrumb=1">
<xsl:for-each select="node">
<a id="sidemenuitem" href="{@url}">
<xsl:choose>
<xsl:when test="@breadcrumb = 1 and @selected = 1">
<li class="subitem active">
<span>
<xsl:value-of select="@text" />
</span>
</li>
</xsl:when>
<xsl:otherwise>
<li class="subitem">
<span>
<xsl:value-of select="@text" />
</span>
</li>
</xsl:otherwise>
</xsl:choose>
</a>
</xsl:for-each>
</xsl:if >
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="NoChildren">
<!-- If the Active page has no children -->
<xsl:for-each select='/Root/root/node'>
<xsl:if test="@selected=1">
<xsl:if test="not(node)">
<xsl:text>true</xsl:text>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>