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
精彩评论