dnn nodeselector show show siblings if no children
dnn nodeselector show show siblings if no children
我当前的菜单模板如下:
<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>
[/?]
[/>]
这会显示当前页面的 children,如果您单击其中一个 children,它将显示该页面的兄弟页面。
现在我希望它显示 children 如果它有的话,否则它应该显示它的兄弟姐妹。
我该怎么做?
我不太清楚你的意思。但是我使用下面的代码生成带有子菜单的菜单树。
<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>
[/>]
我在以下帮助下找到了答案:
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>
我当前的菜单模板如下:
<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>
[/?]
[/>]
这会显示当前页面的 children,如果您单击其中一个 children,它将显示该页面的兄弟页面。
现在我希望它显示 children 如果它有的话,否则它应该显示它的兄弟姐妹。
我该怎么做?
我不太清楚你的意思。但是我使用下面的代码生成带有子菜单的菜单树。
<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>
[/>]
我在以下帮助下找到了答案: 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>