Is it smart to include labels in the if statement?
P粉850680329
P粉850680329 2024-02-25 21:14:15
0
1
396

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粉850680329
P粉850680329

reply all(1)
P粉231112437

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}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!