DDRMenu Token Templates
DNN Version: 09.02.00
• 4 minutes to read
• 4 minutes to read
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.
Tokens
The full set of tokens available currently for each menu node (page) are:
NODE
- A pageID
- The page IDTEXT
- The page name (i.e., what should normally be displayed in the menu)TITLE
- The full page titleURL
- The page URLENABLED
- Whether the page is enabledSELECTED
- Whether the page is selectedBREADCRUMB
- Whether the page is in the current breadcrumbSEPARATOR
- Whether the node is a separatorICON
- The URL of the page iconLARGEIMAGE
- The URL of the large page icon (DNN 6 only)FIRST
- Whether the page is the first in its levelLAST
- Whether the page is the last in its levelONLY
- Whether the page is the only one in its levelDEPTH
- The depth of the current page in the menu structure (starting at 0)TARGET
- The target window for the url defined for the page (_new or null)KEYWORDS
- The keywords defined for the current pageDESCRIPTION
- The description of the current pageTARGET
- The target property is used to identify the browser window.
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 optionalMODE
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 what you see below:
<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 additional examples, download the DDR Menu starter templates.