ctdesign87 Posted June 23, 2011 Share Posted June 23, 2011 hi therei have managed to sucessfully change the product-list-tpl depending on which category is selected.however i have an issue related to efficiency.within the product-list.tpl file i've inserted the following code: {if $category->id == 75 || $category->id == 76 || $category->id == 77 || $category->id == 78 || $category->id == 79 || $category->id == 80 || $category->id == 81 || $category->id == 82 || $category->id == 83 || $category->id == 84 || $category->id == 85 || $category->id == 86 || $category->id == 87 || $category->id == 88 || $category->id == 89 || $category->id == 90 || $category->id == 91 || $category->id == 92 || $category->id == 93 || $category->id == 94 || $category->id == 95 || $category->id == 96 || $category->id == 97 || $category->id == 98 || $category->id == 99} surely there would be a more efficient way for the server going through this list of numbers and having to see if it matches to satisfy the conditions of the if statement.can anyone suggest a step by step process to making this more efficient? im looking into arrays atm, but am getting confused atm. 1 Link to comment Share on other sites More sharing options...
realayumi Posted December 11, 2011 Share Posted December 11, 2011 me also need this information. Before i found this, but i forget to bookmark. Anyone can help? Link to comment Share on other sites More sharing options...
S7 Media Ltd Posted April 4, 2013 Share Posted April 4, 2013 hi there i have managed to sucessfully change the product-list-tpl depending on which category is selected. however i have an issue related to efficiency. within the product-list.tpl file i've inserted the following code: {if $category->id == 75 || $category->id == 76 || $category->id == 77 || $category->id == 78 || $category->id == 79 || $category->id == 80 || $category->id == 81 || $category->id == 82 || $category->id == 83 || $category->id == 84 || $category->id == 85 || $category->id == 86 || $category->id == 87 || $category->id == 88 || $category->id == 89 || $category->id == 90 || $category->id == 91 || $category->id == 92 || $category->id == 93 || $category->id == 94 || $category->id == 95 || $category->id == 96 || $category->id == 97 || $category->id == 98 || $category->id == 99} surely there would be a more efficient way for the server going through this list of numbers and having to see if it matches to satisfy the conditions of the if statement. can anyone suggest a step by step process to making this more efficient? im looking into arrays atm, but am getting confused atm. Can I just say a huge thank you, this as helped me out tremendously! Thanks Link to comment Share on other sites More sharing options...
bumerang07 Posted June 28, 2013 Share Posted June 28, 2013 Hi! I know it's a litte bit old, but I would use 'in_array' function. First define an array containning all th ID's You want. Then check if the '$categoty->$id' is in that array. Below is an example: {$id_array = [78,79,...,90,91]} {if in_array($category->$id, $id_array)} do something {/if} Link to comment Share on other sites More sharing options...
vekia Posted June 28, 2013 Share Posted June 28, 2013 you can also use front controller to define tpl file, it's in my opinion better solution (more clean) 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