开发者

How to do assignment in smarty?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜