Anissneo Posted July 25, 2017 Share Posted July 25, 2017 Hi,I followed this solution here (thank you vekia) and it works fine. But in this code (used in product.tpl) <ul class="productcats"> {foreach from=Product::getProductCategoriesFull(Tools::getValue('id_product')) item=cat} {if $cat.id_category!=2} <li><a href="{$link->getCategoryLink({$cat.id_category})}" title="{$cat.name}">{$cat.name}</a></li> {/if} {/foreach} </ul> I want to exclude many category. So i tried {if $cat.id_category!=2 || $cat.id_category!=3 || $cat.id_category!=4} But it doesn't work. And i want to customize name of category and subcategory with css. Please help Link to comment Share on other sites More sharing options...
NemoPS Posted July 26, 2017 Share Posted July 26, 2017 If you want to exclude all, you must use AND instead of || Link to comment Share on other sites More sharing options...
ventura Posted July 26, 2017 Share Posted July 26, 2017 Use in_array it´s a good practique Try something like this {if !in_array($category.id_category, array(4,25,36,55))} Link to comment Share on other sites More sharing options...
Anissneo Posted July 26, 2017 Author Share Posted July 26, 2017 it doesn't work with "AND". {if !in_array($category.id_category, array(4,25,36,55))} array crashes my site. it seems like he don't accept php functions. I used {if $cat.id_category => 80 AND $cat.id_category < 85} and it works fine (categories i want to be excluded are between 80 and 85) thanks for your responses Link to comment Share on other sites More sharing options...
Anissneo Posted July 26, 2017 Author Share Posted July 26, 2017 SOLVED WITH {if $cat.id_category!=2 && $cat.id_category!=3 && $cat.id_category!=4} Link to comment Share on other sites More sharing options...
ventura Posted July 27, 2017 Share Posted July 27, 2017 it doesn't work with "AND". {if !in_array($category.id_category, array(4,25,36,55))} array crashes my site. it seems like he don't accept php functions. I used {if $cat.id_category => 80 AND $cat.id_category < 85} and it works fine (categories i want to be excluded are between 80 and 85) thanks for your responses It was just an example. In this case {if !in_array($cat.id_category, array(4,25,36,55))} 1 Link to comment Share on other sites More sharing options...
NemoPS Posted July 28, 2017 Share Posted July 28, 2017 The smarty version is |in_array:[the array...] 1 Link to comment Share on other sites More sharing options...
ventura Posted July 29, 2017 Share Posted July 29, 2017 Sure. Inside brackets php format it´s also accepted Link to comment Share on other sites More sharing options...
Anissneo Posted July 29, 2017 Author Share Posted July 29, 2017 It was just an example. In this case {if !in_array($cat.id_category, array(4,25,36,55))} yes, good Link to comment Share on other sites More sharing options...
Norben Posted November 18, 2020 Share Posted November 18, 2020 Hi, Please for this code : <ul class="productcats"> {foreach from=Product::getProductCategoriesFull(Tools::getValue('id_product')) item=cat} {if $cat.id_category!=2} <li><a href="{$link->getCategoryLink({$cat.id_category})}" title="{$cat.name}">{$cat.name}</a></li> {/if} {/foreach} </ul> In my case i want to display only "Level depth 3" Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now