开发者

How to do assignment in smarty?

开发者 https://www.devze.com 2023-01-21 18:49 出处:网络
I tried this开发者_高级运维 way,but seems not working: {if $i == 1} $value = $recommend[3]; {/if}

I tried this开发者_高级运维 way,but seems not working:

{if $i == 1}
    $value = $recommend[3];
{/if}

Does smarty support assignment operation?


To assign variables within a template, do:

{if $i == 1}
    {assign var='value' value=$recommend[3]}
{/if}


There is assign() method for that. Check it out here:

http://www.smarty.net/manual/en/api.assign.php


Another option besides assign() ( which is probably better from separation of code and presentation point of view) is http://www.smarty.net/manual/en/language.function.php.php

0

精彩评论

暂无评论...
验证码 换一张
取 消