A
A
Anton2016-12-08 14:30:33
Smarty
Anton, 2016-12-08 14:30:33

How to compare words in Smarty Template?

How to compare Russian text in smarti? Seems like strstr should work... but no...
$payment_method.desc - contains Russian text
There is a code:

{assign "desc" $payment_method.desc}
{assign "var_1" "терминалы."}
{$var_1|@var_dump}
{$desc|@var_dump}
{if $desc|@mb_stristr:$var_1|@var_dump}Да!{/if}
{if $desc|@mb_strstr:$var_1|@var_dump}Да!{/if}
{if $desc|@strstr:$var_1|@var_dump}Да!{/if}

Works if you use latin characters

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ITLandgraf, 2016-12-22
@ITLandgraf

You need to check the encoding of both strings: "terminals." in the code and the value of $payment_method.desc.
For the test, you can assign a text constant above $payment_method.desc also in the code.
Everything must be in UTF-8.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question