I would like to have an if statement (or something that does the following) inside smarty's include tag. I have the following containing tags:
{include file="controls/control_input.tpl" //some other smarty variables mask=$itemType->mask mask=$field['mask'] }
My goal is that if field["mask"] = to "", then mask is set to itemType->mask, otherwise it should be set to field["mask"]. However, I can't seem to add an if statement inside the include tag.
P粉2311124372024-02-26 17:44:55
You can use if else condition before including the template file and then pass the mask variable inside the include tag as shown below,
{if $field['mask'] eq ""} {$mask = $itemType->mask} {else} {$mask = $field['mask']} {/if} {include file="controls/control_input.tpl" mask=$mask}