I have assigned a variable based on the number of characters in a name, which returns an integer (1,2,3, etc). I would like to further add an {if} statement to show an option if the option name matches the variable. The option names are 5″ x 7″ – 1, 5″ x 7″ – 2, 5″ x 7″ – 3 etc.
{assign var="numberofcharacters" value=$smarty.get.name|count_characters}
{if $vr.variant_name == '5" x 7" - $numberofcharacters' || $vr.variant_name == '8" x 11" - $numberofcharacters'}
...
{/if}
This is not producing a result, even though I have 3 options that should be showing. Please could somebody let me know what is wrong with my {if} statement?
I cannot use:
{if $vr.variant_name|contains:}
because if the value returned is 1, then 10, 11 and 12 are also included when I just need 1 included.
MANY THANKS
Smarty3 with escaped quotes:
or
or Smarty2
or using the cat modifier
throwing things together should be easy enough…
But… If you have a fixed pattern you want to check, you might want to use a regular expression instead? or a substr?
(you should do stuff like that in your PHP though…)