DotNetNuke Wiki


DDRMenu XSLT templates

Modified on 2012/06/28 05:59 PM by cathal Categorized as DDRMenu
This page describes how the DDRMenu XSLT template processor works. XSLT-based templates provide a good compromise of coverage and power, being supported in all versions of DotNetNuke and providing significantly more flexibility than token templates (although at the cost of extra complexity).

Table Of Contents [Hide]


XML format»

The best way to see the XML structure provided to the XSLT stylesheet is to look at the output of the DumpXML template). For reference, the full set of attributes and elements of a menu <node> is as follows

  • @id - The page ID
  • @text - The page name (i.e. what should normally be displayed in the menu)
  • @title - The full page title
  • @url - The page URL
  • @enabled - Whether the page is enabled
  • @selected - Whether the page is selected
  • @breadcrumb - Whether the page is in the current breadcrumb
  • @separator - Whether the node is a separator
  • @icon - The URL of the page icon
  • @largeimage - The URL of the large page icon (DNN 6 only)
  • @first - Whether the page is the first in its level
  • @last - Whether the page is the last in its level
  • @only - Whether the page is the only one in its level
  • @depth - The depth of the current page in the menu structure (starting at 0)
  • @commandname - The action command name (action menus only)
  • @commandargument - The action command argument (action menus only)
  • keywords - The keywords defined for the current page
  • description - The description of the current page
  • node - A child node of this node

Extension functions»

To access XSL extension functions, add a namespace reference to urn:ddrmenu to your stylesheet, e.g.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ddr="urn:ddrmenu">

This will give you access to the following functions:

  • UserIsInRole(roleName): returns true or false depending on whether the current user is in the specified role. e.g.
    <xsl:if test="ddr:UserIsInRole('Administrators')='true'">...</xsl:if>
  • GetString(tokenName, resourceFile): returns a localised string (using the standard DotNetNuke Localization.GetString API). e.g.
    <xsl:value-of select="ddr:GetString('cmdCreate',
    
    'admin/authentication/app_localresources/login.ascx.resx')" />
    <xsl:value-of select="ddr:GetString('MyToken', 'MyCustom.resx')" />


Example»

A simple example might look like this:

<?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:template match="/*">
		<xsl:apply-templates select="root" />
	</xsl:template>
	<xsl:template match="root">
		<ul>
			<xsl:apply-templates select="node" />
		</ul>
	</xsl:template>
	<xsl:template match="node">
		<li>
			<xsl:attribute name="class">
				<xsl:if test="@first = 1">first</xsl:if>
				<xsl:if test="@last = 1"><xsl:text>&#32;</xsl:text>last</xsl:if>
				<xsl:if test="@selected = 1"><xsl:text>&#32;</xsl:text>selected</xsl:if>
			</xsl:attribute>
			<xsl:choose>
				<xsl:when test="@enabled = 1">
					<a href="{@url}">
						<xsl:value-of select="@text" />
					</a>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="@text" />
				</xsl:otherwise>
			</xsl:choose>
			<xsl:if test="node">
				<ul>
					<xsl:apply-templates select="node" />
				</ul>
			</xsl:if>
		</li>
	</xsl:template>
</xsl:stylesheet>

Tutorials»




Related content»

Attend A Webinar
Start  Professional Edition Trial
Have Someone Contact Me

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

Sponsors

DotNetNuke Corporation

DotNetNuke (DNN) provides a suite of solutions that make designing, building and managing feature-rich sites and communities fast, easy and cost-effective. The DotNetNuke Platform CMS is the foundation for more than one million websites worldwide. DNN Social, our newest solution, enables businesses to create immersive, interactive communities. Thousands of organizations like True Value Hardware, Bose, Cornell University, Glacier Water, Dannon, Delphi, USAA, NASCAR, Northern Health and the City of Denver have leveraged DNN to deploy highly engaging business- critical websites. Our rapid growth in product sales and deployments resulted in DotNetNuke Corp. being named one of the fastest growing private companies in America by Inc. Magazine in 2011 and 2012.