Dell PowerConnect W Clearpass 100 Software 3.9 Deployment Guide - Page 445
Foreach Text Blocks, Modifiers
View all Dell PowerConnect W Clearpass 100 Software manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 445 highlights
{/section} Note that the content after a {sectionelse} tag is included only if the {section} block would otherwise be empty. Foreach Text Blocks An easier to use alternative to the {section} ... {/section} tag is to use the {foreach} ... {/foreach} block: {foreach key=key_var item=item_var from=$collection} {$key_var} = {$item_var} {foreachelse} {/foreach} The advantage of this syntax is that each item in the collection is immediately available as the named item variable, in this example {$item_var}. This construct is also useful when iterating through associative arrays indexed by key, as the key is immediately available with each item. A name= attribute may be supplied with the opening {foreach} tag. When a name is supplied, the following additional Smarty variables are available for use inside the {foreach} ... {/foreach} block: {$smarty.foreach.name.first} - true if the item being processed is the first item in the collection {$smarty.foreach.name.last} - true if the item being processed is the last item in the collection {$smarty.foreach.name.index} - counter for the current item, starting at 0 for the first item {$smarty.foreach.name.iteration} - counter for the current item, starting at 1 for the first item {$smarty.foreach.name.total} - value indicating the total number of items in the collection Note that the content after a {foreachelse} tag is included only if the {foreach} block would otherwise be empty. Modifiers Smarty provides modifiers that can be used to gain greater control over the formatting of data. Modifiers can be included by following a variable with a vertical bar | and the name of the modifier. Any arguments to the modifier can be specified using a colon : followed by the arguments. The following example prints a date using the YYYY-MM-DD syntax: {$expire_time|nwadateformat:"%Y-%m-%d"} See "Date/Time Format Syntax" in this chapter for detailed information on the date/time format modifiers. See Table 40. Table 40 Smarty Modifiers Modifier Description htmlspecialchars nl2br number_format nwadateformat Escapes characters used in HTML syntax with the equivalent HTML entities (& for &, < for < and > for >) Replaces newline characters in the value with HTML line breaks () Formats a numerical value for display; an optional modifier argument may be used to specify the number of decimal places to display (default is 0) Date/time formatting; see "nwadateformat Modifier" in this chapter for details about this modifier function ClearPass Guest 3.9 | Deployment Guide Reference | 445