moy2010 Posted January 26, 2016 Share Posted January 26, 2016 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 . 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 More sharing options...
bellini13 Posted January 26, 2016 Share Posted January 26, 2016 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 1 Link to comment Share on other sites More sharing options...
moy2010 Posted January 26, 2016 Author Share Posted January 26, 2016 Got it. So, first I must store te array in a variable and then call it . Thanks, Bellini13! 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