Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting a var in smarty with a condition

I really like the smarty documentation but sometimes its hard to find easy stuff... so heres my question. Is it possible to set a var in a condition? theres a large template with many euro signs. now there is another new language but they not paying with euro. so instead of settung up a condition for the language around each euro sign. i want to use a var which is set at the start of my template once with the language condition like:

{if $lang eq 'ch'}
{*need to set "CHF" as a smarty or php var*}
{else}
{*need to set "EURO" as a smarty or php var*}
{/if}

<div class="payment">{$price} {*CHF or EURO var*}</div>
like image 362
ggzone Avatar asked Nov 02 '25 21:11

ggzone


1 Answers

{if $lang eq 'ch'}
    {assign var="currency" value="CHF"}
{else}
    {assign var="currency" value="EURO"}
{/if}

<div class="payment">{$price} {$currency}</div>
like image 138
Ermat Alymbaev Avatar answered Nov 05 '25 10:11

Ermat Alymbaev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!