yoyo
yoyo

Reputation: 1133

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?

Upvotes: 2

Views: 3402

Answers (3)

webbiedave
webbiedave

Reputation: 48897

To assign variables within a template, do:

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

Upvotes: 4

Mark Steudel
Mark Steudel

Reputation: 1682

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

Upvotes: 0

Sarfraz
Sarfraz

Reputation: 382776

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

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

Upvotes: 1

Related Questions