DotNetNuke Wiki


DDRMenu token templates

Modified on 2011/07/17 08:02 AM by MarkXA Categorized as DDRMenu, guide
This page describes how the DDRMenu token template processor works. Token-based templates are supported in all versions of DNN and provide a simple templating option if the additional programming power of XSLT or Razor are not required.

Table Of Contents [Hide]


Tokens»

The full set of tokens available currently for each menu node (page) are:

  • NODE - A page
  • 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)
  • KEYWORDS - The keywords defined for the current page
  • DESCRIPTION - The description of the current page

You can see an example of the values these take in the output of the DumpXML template).

Directives»

The following directives are available in a token template:

  • [=TOKEN]
    Simply outputs the value of the given token.
  • [?TOKEN]...[/?]
    Only output if the token is defined. This will generally be used as [?NODE]...[/?] to output a section if there are any child nodes, or as [?SELECTED]...[/?] etc to output something only if the current node is selected. You can also use [?!TOKEN]...[/?] (output if token is not defined) and [?TOKEN]...[?ELSE]...[/?].
  • [*TOKEN]...[/*]
    Outputs the contents for each occurrence of the given token. In practice this means [*NODE]...[/*] to produce output for each menu node at the current level.
  • [*>TOKEN-MODE]
    Outputs the contents of a sub-template for each occurrence of the given token. The optional MODE parameter allows you to specify more than one sub-template for a given token. For example, you might define [>NODE-TOP] for top-level menu nodes and [>NODE-SUB] for sub-menus.
  • [>TOKEN-MODE]...[/>]
    Defines a sub-template (called using the above directive).

Example»

A very simple example to output an unordered list with relevant classes on the LI elements might look like this:

<ul>
	[*>NODE]
</ul>

[>NODE]
	<li class="[?FIRST]first[/?][?LAST] last[/?][?SELECTED] selected[/?]">
		[?ENABLED]
			<a href="[=URL]">[=TEXT]</a>
		[?ELSE]
			[=TEXT]
		[/?]
		[?NODE]
			<ul>
				[*>NODE]
			</ul>
		[/?]
	</li>
[/>]
For live examples, download the DDR Menu starter templates.

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.