ken ken - 3 years ago 288
Smarty Question

Using default modifiers

I am trying to step a bit beyond the basic usage of Smarty and ran into a small problem using the default "capitalize" modifier. I am operating with the assumption that no explicit calls need to be made to use this operator so in my template I have the following:

{* Smarty Part: Add-ins *}

<div class="control-group form-inline">
<label class="control-label">Add-ins:</label>
<div class="controls ">
{foreach $add_ins as $add_in}
<label class="checkbox inline"><input type="checkbox" cf-change="toggle-field::#{$add_in}-add-in"> {$add_in|capitalize}</label>

If I were to replace the:




It would work fine but adding the modifier gives me the following error:

PHP Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template [FILE_PATH] on line 7 "&lt;label class=&quot;checkbox inline&quot;&gt;&lt;input type=&quot;checkbox&quot; cf-change=&quot;toggle-field::#{$add_in}-add-in&quot;&gt; {$add_in|capitalize}&lt;/label&gt;" unknown modifier "capitalize"'

Any help would be greatly appreciated.

Answer Source

When using above code from ken you could also/better use

$object->addPluginsDir(LG_FE_DIR . '/templates/plugins_dir');

and then you don't have to take care about default stuff.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download