在smarty中找不到带有strpos的单词(prestashop)
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?
我将编辑在prestashop中生成传送单的.tpl。 p> 我想检查订单中的一个产品是否包含标题中的特定单词。 如果标题包含该单词,那么我将在html中生成一个表 p>
经过简单的研究 ,我发现一些用户使用 我哪里错了? p> \ n div> strpos code>来做到这一点,但我的编辑不起作用: p>
{if strpos($ order_detail。 product_name,'word')!== false}
...
{/ if}
code> pre>
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