eghambob Posted November 28, 2009 Share Posted November 28, 2009 Hi there,Would anyone know the correct Smarty syntax for adding more than one category id in an {if} statement?For example:{if $product->id_category_default == 6} is for category id that equals 6, but what if I wanted to target other specific ids as well such as:{if $product->id_category_default == 6 5 3 27}I've googled but I dont know enough to describe the problem, so haven't found how. I've tried commas and colons just guessing but of course the page doesnt load so I need to know the correct syntax.Any help would be appreciated,Regards,Rob. Link to comment Share on other sites More sharing options...
Trip Posted November 28, 2009 Share Posted November 28, 2009 You are looking for logical operatorsIn smarty they look the same like in PHP <?php $a = 3; if($a == 1 || $a == 2 || $a == 3) { echo "1,2 or 3 found"; } ?> Link to comment Share on other sites More sharing options...
Gregory Roussac Posted November 28, 2009 Share Posted November 28, 2009 I think you could assign an array in php to smarty and use the in_array function in the tpl. have not tested but this might seems cleaner.Cheers Link to comment Share on other sites More sharing options...
eghambob Posted November 28, 2009 Author Share Posted November 28, 2009 Ok thanks for the replies, I hoped it would be a simple addition of a seperating character in between the ids, however I'll take on board your suggestions.Thanks again,Rob. Link to comment Share on other sites More sharing options...
eghambob Posted November 28, 2009 Author Share Posted November 28, 2009 Ok it works if I do as suggested, I had a typo in there:{if $product->id_category_default == 3 || $product->id_category_default == 5}So many thanks for the help!Rob. Link to comment Share on other sites More sharing options...
Recommended Posts