User's Manual

482 | Reference Dell Networking W-ClearPass Guest 6.4 | User Guide
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:
l {$smarty.foreach.name.first} – true if the item being processed is the first item in the collection
l {$smarty.foreach.name.last} – true if the item being processed is the last item in the collection
l {$smarty.foreach.name.index} – counter for the current item, starting at 0 for the first item
l {$smarty.foreach.name.iteration} – counter for the current item, starting at 1 for the first item
l {$smarty.foreach.name.total} – value indicating the total number of items in the collection
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" on page 496 for detailed information on the date/time format modifiers, and
see Table 114.
Modifier Description
htmlspecialchars Escapes characters used in HTML syntax with the equivalent HTML entities (& for
&, &lt; for < and &gt; for >)
nl2br Replaces newline characters in the value with HTML line breaks (<br>)
number_format 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)
nwadateformat Date/time formatting; see "nwadateformat Modifier" on page 496 for details about
this modifier function
nwatimeformat Date/time formatting; see "Date/Time Format String Reference" on page 497 for
details about this modifier function
nwamoneyformat Formats a monetary amount for display purposes; an optional modifier argument may
be used to specify the format string. This modifier is equivalent to the
NwaMoneyFormat() function; see "NwaMoneyFormat" on page 501 for details.
strtolower Converts the value to lowercase
strtoupper Converts the value to uppercase
ucfirst Converts the first character of the value to uppercase
ucwords Converts the first character of each word in the value to uppercase
Table 114: Smarty Modifiers
Predefined Template Functions
Template functions are used to perform different kinds of processing when the template is used. The result of
a template function takes the place of the function in the output of the template.