rosuandreimihai rosuandreimihai - 1 month ago 18
Smarty Question

Prestashop smarty {if} statement

I have a problem regarding a simple statement in prestashop's smarty tpl file
I am trying to restrict access for some html code using a if statement, just like the one below:

{if $page_name != 'cms' || $page_name != 'module-checkout-payment' || $page_name != 'countrypages' || $page_name != 'dpage'}
/* stuff here */
{/if}


The code above doesn't work, but if I only use one condition it will work, just like this:

{if $page_name != 'cms'}
/* stuff here */
{/if}


I still don't get it, what is wrong.. Could someone help me?
Thank you..

Answer

I think you are using the wrong operator. With the OR operator your code will fire even if $page_name is some of your restricted values. Try with '&&' instead of '||'.