动态显示菜单节点及其子节点DNN

时间:2015-09-22 14:22:43

标签: menu dotnetnuke html-encode ascx

我已经使用选择特定节点的dnn:菜单在皮肤文件中对其进行了硬编码,但看起来id必须创建几个额外的皮肤来区分NodeMenu项目(其中4个)之间的NodeSelectors。

有没有办法,在任何给定的页面上使用相同的皮肤文件,我可以告诉我在哪个rootMenu项目,循环通过它的第一级子页面作为选项卡,同时将他们的孩子列在可扩展的手风琴部分中它去了?

呃......越简越好。

使用

<ddr:MENU menustyle="Accordion" runat="server" /></dnn:MENU>

这个Accordian.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:param name="CSSClass" />
  <xsl:template match="/*">
    <xsl:apply-templates select="root" />
  </xsl:template>
  
   <xsl:template match="root/node">
	 	<xsl:if test="@breadcrumb = 1 and count(descendant::node) > 0">

			<script type="text/javascript">
	      jQuery(function($) {
	        var options = { initialIndex: -1 };
	        $.extend(options, { <xsl:apply-templates select="node" mode="breadcrumb" /> }, <xsl:value-of select="$Options" />);
					  $("#<xsl:value-of select="$ControlID" />").tabs(".toolsaccordion div.pane", options);
				});
			</script>
			<div id="{$ControlID}" class="toolsaccordion">
				<xsl:apply-templates select="node" />
			</div>
		</xsl:if>
  </xsl:template>
  <xsl:template match="node" mode="breadcrumb">
    <xsl:if test="@breadcrumb = 1">initialIndex: <xsl:value-of select="position() - 1" /></xsl:if>
  </xsl:template>
	<xsl:template match="node">
		<h3>
			
				<xsl:value-of select="@text" />
			
		</h3>
		<div class="pane">
			<xsl:apply-templates select="node" mode="sub">
				<xsl:with-param name="level" select="0" />
			</xsl:apply-templates>
		</div>
	</xsl:template>
	<xsl:template match="node" mode="sub">
		<xsl:param name="level" />
		<xsl:choose>
			<xsl:when test="@enabled = 0">
				<div>
					<xsl:call-template name="indent">
						<xsl:with-param name="level" select="$level" />
					</xsl:call-template>
					<xsl:value-of select="@text" />
				</div>
			</xsl:when>
			<xsl:otherwise>
				<a style="display:block" href="{@url}">
					<xsl:call-template name="indent">
						<xsl:with-param name="level" select="$level" />
					</xsl:call-template>
					<xsl:value-of select="@text" />
				</a>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:apply-templates select="node" mode="sub">
			<xsl:with-param name="level" select="$level + 1" />
		</xsl:apply-templates>
	</xsl:template>
	<xsl:template name="indent">
		<xsl:param name="level" />
		<xsl:if test="$level &gt; 0">
			&#160;&#160;<xsl:call-template name="indent">
				<xsl:with-param name="level" select="$level - 1" />
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>
Here is the menudef.xml




<? xml version = "1.0"
encoding = "utf-8" ?>
  < manifest >
  < template > Accordion.xslt < /template>
  <scripts>
    <script jsObject="jQuery" / >
  < script jsObject = "jQuery.tools.tabs" > http: //www.itdraws.com/js/flowplayer.org-1.1.2-jquery.tools.min.js</script>
  < /scripts>
  <stylesheets>
    <stylesheet>[MANIFEST]/tabs - accordion.css < /stylesheet>
  </stylesheets >
  < defaultClientOptions >
  < clientOption name = "tabs"
type = "string"
value = "h3" / >
  < clientOption name = "effect"
type = "string"
value = "slide" / >
  < clientOption name = "event"
type = "string"
value = "onclick" / >
  < /defaultClientOptions>
</manifest >

3 个答案:

答案 0 :(得分:0)

嗯,使用Razor模板在条件内容中工作可能更容易。

(您可以查看MegaMenu模板作为示例。)

答案 1 :(得分:0)

一个非常简短的答案是,您将以&#34;手风琴格式生成HTML(使用您正在使用的任何模板)&#34;然后使用jquery.accordion完成手风琴的工作。

查看jquery文档,了解您需要生成的HTML结构的示例。

答案 2 :(得分:0)

我在这里有几个答案可行。

DNN ascx if / else()语句如下所示:

<% if (singleConditionExample)  { %>
    alert("Hello World");

<% } else if (multipleConditionsHere() || multipleConditionsHere() && multipleConditionsHere())   { %>    // standard operators. you get the idea.
    alert("elseifConditionsHere");

<% } else { %>
    alert("Else Msg");

<% } %>

至于获取DNN页面tabId,tabName,ParentId,这些都进入了if()条件。

//来自DNN BREADCRUB的当前页面根父母

PortalSettings.ActiveTab.BreadCrumbs[0]

// CURRENT DNN PAGE NAME

PortalSettings.ActiveTab.TabName.Equals("Wealth Management")

// CURRENT DNN PAGE ID NUM

<%=PortalSettings.ActiveTab.TabID %>

// CURRENT DNN PAGE PARENT ID

DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings().ActiveTab.ParentId.Equals(480)

如果您想将它们写入页面:

<%=PortalSettings.ActiveTab.BreadCrumbs(0).FullUrl%>

我确信还有更多需要学习的内容,当我了解更多内容时,因为它与获取DNN页面ID,面包师等有关...我将更新此答案。

干杯!