Jump to content

Select Array For $Id_Category


moy2010

Recommended Posts

Hi, Prestashop community :). I'm trying to display some content depending on the product's category id, but so far I'm only able to do so for 1 category ID. I'm not PHP savvy, so I'm kind of blind-trying to get it done :P. So far, this is the code that is working:

 

{if $feature.name == 'XXX' && $id_category != '7'}....

 

I've tried to use an array as following:

 

{if $feature.name == 'Socket' && $id_category != array(7,116)}

 

But it didn't work :/. I've also tried to use some other PHP operators such as ||, but no matter what I try, it has not worked yet.

I hope someone cand shed some light on me on this so that I can see what the right syntax should be >.<

 

Thanks in advance!

Link to comment
Share on other sites

I think you are wanting to use the in_array function. 

 

first define the array of category ids to check for

{$id_array = [7,116]}

then use in_array function in your condition, something like this.

{if $feature.name == 'Socket' && $id_category !in_array($id_category, $id_array)}

remember google is your friend, a simple google search for "smarty array condition" would probably get you this information

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...