I am going to edit the .tpl that generate delivery slips in prestashop.
I want to check if one product in the order contains a particular word in title. If the title contains that word, then I will generate a table in html
After a simple research, I've find that some users used strpos
to do that, but my edit doesn't work:
{if strpos($order_detail.product_name, 'word') !== false}
...
{/if}
Where I'm wrong?
I think you can't use the strpos
function in smary's {if}
statement.
{if},{elseif},{else}
documentation states:
If securty (sic!) is enabled, only PHP functions from $php_functions property of the securty policy are allowed. See the Security section for details.
The Security sections says:
$php_functions is an array of PHP functions that are considered trusted and can be used from within template. To disable access to all PHP functions set $php_functions = null. An empty array ( $php_functions = array() ) will allow all PHP functions. The default is array('isset', 'empty', 'count', 'sizeof', 'in_array', 'is_array','time','nl2br').
strpos
is not in this list.
So it seems that Security is enabled on your part.
You should use strpos
in your program logic and store the result into a variable which you then check in the smarty template