Dell Powerconnect W-ClearPass Virtual Appliances W-ClearPass Guest 6.0 Deploym - Page 265
Script Blocks, Repeated Text Blocks, else}, literal}, ldelim}, else}, item_var}
View all Dell Powerconnect W-ClearPass Virtual Appliances manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 265 highlights
{/if} The condition tested in the {if} ... {/if} block should be a valid PHP expression. The {else} tag does not require a closing tag. Script Blocks The brace characters { and } are specially handled by the Smarty template engine. Using text that contains these characters, such as CSS and JavaScript blocks, requires a Smarty block {literal} ... {/literal}: {literal} {/literal} Failing to include the {literal} tag will result in a Smarty syntax error when using your template. Single instances of a { or } character can be replaced with the Smarty syntax {ldelim} and {rdelim} respectively. Repeated Text Blocks To repeat a block of text for each item in a collection, use the {section} ... {/section} tag: {section loop=$collection name=i} {$collection[i].name} {sectionelse} {/section} 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: 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 Dell Networking W-ClearPass Guest 6.0 | Deployment Guide Script Blocks | 265