nickosn Posted January 26, 2015 Share Posted January 26, 2015 Hi, One of the problems I am trying to resolve is this: I am setting up a site that needs to display different features per category So the first thing I did is to add the following code to the product-list.tpl file {if isset($product.features)} <div class="features"> {foreach from=$product.features item=feature name=pr_features} {if $feature.id_feature == 8 OR $feature.id_feature == 11 OR $feature.id_feature == 12} <div> {$feature.name}: <span>{$feature.value}</span> </div> {/if} {/foreach} {/if} This add the features I want to the category. (Note that set of feature will be different in other categories or no features at all) The second thing I did is to create a category-computers.tpl file and a product-computers-list.tpl file And then adapting the code from this link https://www.prestashop.com/forums/topic/392095-how-to-different-producttpl-template-on-a-page-per-product-and-a-per-category-basis/ I added if ($this->category->id>=5 && $this->category->id<=12 || $this->category->id==11){ $this->setTemplate(_PS_THEME_DIR_.'category-computers.tpl'); // template file for caregories between 5 and 7, OR category 11 } else { $this->setTemplate(_PS_THEME_DIR_.'category.tpl'); // DEFAULT template } to the controllers/front/CategoryController.php And the third thing I did is to change the category-computers.tpl {include file="./product-list.tpl" products=$products} to {include file="./product-list-computers.tpl" products=$products} Now I get a <div class="features">undefined</div> error Please please someone tell me that's it's easier than that! I am sure that if I try to upgrade prestashop at one some point things will get messed up Kind Regards 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