codefritz Posted November 15, 2013 Share Posted November 15, 2013 Would like to have depending on the selected category a different product.tpl. Thanks a lot for your help... Link to comment Share on other sites More sharing options...
NemoPS Posted November 15, 2013 Share Posted November 15, 2013 This will required a whole lot of modifications. Basically, you want to edit the product controller, especially the initContent function, so that you ccan return a different template based on the id_category_default. Of course, if you are not happy in setting this up manually, you have to override the category class as well, add a new column to ps_category like template_name, then create a back office override as well to manage the template selection So, tons of stuff involved! Link to comment Share on other sites More sharing options...
Ray UK Posted November 17, 2013 Share Posted November 17, 2013 (edited) Would it not work inside the product-list.tpl ? Just something like {if isset($products)} {if catid=="1"} ........ category 1 layout {else} ........ category 2 layout {/if} {/if} Edited November 17, 2013 by MerseyRay (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted November 18, 2013 Share Posted November 18, 2013 hello, yes, you can use this method you can also include own tpl files: {if isset($products)} {if catid=="1"} {include file="./product-list-category1.tpl"} {else} {include file="./product-list-all-other.tpl"} {/if} {/if} Link to comment Share on other sites More sharing options...
NemoPS Posted November 18, 2013 Share Posted November 18, 2013 oh, well, if it's on the category page, then yes, you can also hardcode it as vekia suggested Link to comment Share on other sites More sharing options...
vekia Posted November 18, 2013 Share Posted November 18, 2013 omg i've noticed something. remember to use variable with category id instead of just simple catid in {if catid=="1"} 1 Link to comment Share on other sites More sharing options...
Ray UK Posted November 28, 2013 Share Posted November 28, 2013 Did you manage to achieve what you were after ? If not, I have done something similar, and probably easier. In the header.tpl, start your body tag like this... <body class="{if isset($category)}cat{$category->id|escape:'htmlall':'UTF-8'}{/if} which will set the body class as "cat1, cat2" etc Then in your category.css you can target .cat1 .inline_list { and so on Ive just done this to place different background for each cat, and it worked fine. Hope it helps 1 Link to comment Share on other sites More sharing options...
vekia Posted November 28, 2013 Share Posted November 28, 2013 it's great solution but when someone want to add additional stuff to new template file it will not work Link to comment Share on other sites More sharing options...
Ray UK Posted November 28, 2013 Share Posted November 28, 2013 yes, my solution is just for design. Although they could add extra stuff in a div and 'hide' it off pages that its not needed on ? I know it will still be loaded, but hidden from view Im going to use different layouts for categories. Some using grid view, and some list view. Ill see how it goes Link to comment Share on other sites More sharing options...
vekia Posted November 28, 2013 Share Posted November 28, 2013 i totally agree with you, in my opinion your method is OK, mainly because everything depends on css no core modifications, no HUGE tpl modifications Link to comment Share on other sites More sharing options...
Skydone Posted December 3, 2013 Share Posted December 3, 2013 Hello, I am looking for something similar. I need to add some HTML in product.tpl only for some categories. I was using this product controller override in PS 1.4.7 and it works very fine, but don't works in PS 1.5 http://www.prestashop.com/forums/topic/162917-different-product-template-for-a-specific-category/?do=findComment&comment=793799 Link to comment Share on other sites More sharing options...
jasonbsmith Posted June 29, 2016 Share Posted June 29, 2016 Any module that can be purchased that does this? Link to comment Share on other sites More sharing options...
NemoPS Posted July 1, 2016 Share Posted July 1, 2016 This one: https://dh42.com/prestashop-modules/flex-layout-module/ 1 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