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).
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 pagedescription - The description of the current pagenode - 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> </xsl:text>last</xsl:if>
<xsl:if test="@selected = 1"><xsl:text> </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