metta Posted January 20, 2010 Share Posted January 20, 2010 I am using 3 columns, default template. I would like to make category page in category 3, 4, and 5 with no left and right columns, and the rest of the category pages use default format which include left and right columns. Thank you for the help. Link to comment Share on other sites More sharing options...
rocky Posted January 20, 2010 Share Posted January 20, 2010 Smarty if statements to the rescue yet again!Modify header.tpl in your theme's directory and modify the body tag and change it from: <body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}> to: <body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}{if $smarty.get.id_category == 3 OR $smarty.get.id_category == 4 OR $smarty.get.id_category == 5} class="no_columns"{/if}> and the left column code from: <!-- Left --> {$HOOK_LEFT_COLUMN} to: {if $smarty.get.id_category != 3 AND $smarty.get.id_category != 4 AND $smarty.get.id_category != 5} <!-- Left --> {$HOOK_LEFT_COLUMN} {/if} and change the right column section in footer.tpl in your theme's directory from: <!-- Right --> {$HOOK_RIGHT_COLUMN} to: {if $smarty.get.id_category != 3 AND $smarty.get.id_category != 4 AND $smarty.get.id_category != 5} <!-- Right --> {$HOOK_RIGHT_COLUMN} {/if} Then add the following to global.css to increase the width of the center column when the left and right columns are missing: body.no_columns #center_column { width: 960px; } Change 960px to whatever width is appropriate. 1 Link to comment Share on other sites More sharing options...
metta Posted January 20, 2010 Author Share Posted January 20, 2010 The mod works, after I entered the codes, the left and right column are disappeared, on category 3, 4 and 5.. Nut my entire header and the footer, shift to the far left on the screen.... Link to comment Share on other sites More sharing options...
rocky Posted January 20, 2010 Share Posted January 20, 2010 I've updated my code. Try body.no_columns #center_column instead. Link to comment Share on other sites More sharing options...
metta Posted January 20, 2010 Author Share Posted January 20, 2010 The header is good now, but the footer is still shift to the far left. Link to comment Share on other sites More sharing options...
rocky Posted January 21, 2010 Share Posted January 21, 2010 I just tested the code I wrote above and it is working on my test site. Are you sure you copied it right? I've attached a screenshot of what it looks like on my site. Link to comment Share on other sites More sharing options...
metta Posted January 21, 2010 Author Share Posted January 21, 2010 I just tested the code I wrote above and it is working on my test site. Are you sure you copied it right? I've attached a screenshot of what it looks like on my site. Sorry, it was not working until I cleared my Cache on my browser. :down: Sorry for wasting your time. Thank you very much. Link to comment Share on other sites More sharing options...
Sanis Posted January 27, 2010 Share Posted January 27, 2010 I want to achieve sort like result, but use a different .tpl file for specific category (which is a stripped version of default product list with just product name, price and order button).Is it possible with smarty? Link to comment Share on other sites More sharing options...
MrHieu Posted March 2, 2010 Share Posted March 2, 2010 I want to achieve sort like result, but use a different .tpl file for specific category (which is a stripped version of default product list with just product name, price and order button).Is it possible with smarty? The same question as Sanis's Link to comment Share on other sites More sharing options...
jbjb Posted September 1, 2010 Share Posted September 1, 2010 I want to achieve sort like result, but use a different .tpl file for specific category (which is a stripped version of default product list with just product name, price and order button).Is it possible with smarty? The same question as Sanis's The same question as you two ^^Is it possible to use a specific template for each category ?Thanks ! Link to comment Share on other sites More sharing options...
rocky Posted September 2, 2010 Share Posted September 2, 2010 To call a different product list tpl file depending on the category, you could change line 55 of category.tpl from: {include file=$tpl_dir./product-list.tpl products=$products} to: {if $smarty.get.id_category == 2} {include file=$tpl_dir./product-list2.tpl products=$products} {elseif $smarty.get.id_category == 3} {include file=$tpl_dir./product-list3.tpl products=$products} {/if} Then create product-list2.tpl and product-list3.tpl. Link to comment Share on other sites More sharing options...
Camille Frisch Posted September 3, 2010 Share Posted September 3, 2010 This mod could help a lot, but isnt there a proper way to apply different template on specific conditions ?like a script that would output different $tpl_dir ?(ps : by proper i mean without changing the template files) Link to comment Share on other sites More sharing options...
Camille Frisch Posted September 4, 2010 Share Posted September 4, 2010 I thought it a bit, and came up with a different approach : apply a template depending on the page url.Using url rewrite, have a reference to a template in the url, like http://www.configurateurvisuel.fr/47-t-shirts-isant-v2- where isant-v2 is your referencemy mod will apply the appropriate template (depending on your own set of rules)Heres the french topic, the code is commented in english, feel free to ask if it's not clear enough.http://www.prestashop.com/forums/viewthread/68565/modules_tiers/mod_template_dynamique__utilisez_plusieurs_themes_sur_votre_boutiqueRegardsmika Link to comment Share on other sites More sharing options...
sakrafanas Posted June 26, 2011 Share Posted June 26, 2011 To call a different product list tpl file depending on the category, you could change line 55 of category.tpl from: {include file=$tpl_dir./product-list.tpl products=$products} to: {if $smarty.get.id_category == 2} {include file=$tpl_dir./product-list2.tpl products=$products} {elseif $smarty.get.id_category == 3} {include file=$tpl_dir./product-list3.tpl products=$products} {/if} Then create product-list2.tpl and product-list3.tpl. ----------------------------------------------------------------------------Amazing, thank you, but how to control templates at frontend. User comes to shop, see category and have ability to change category view from list to grid view? Thank you. It would be really nice feature in future releases of prestashop. Link to comment Share on other sites More sharing options...
alanf21 Posted March 30, 2012 Share Posted March 30, 2012 To call a different product list tpl file depending on the category, you could change line 55 of category.tpl from: {include file=$tpl_dir./product-list.tpl products=$products} to: {if $smarty.get.id_category == 2} {include file=$tpl_dir./product-list2.tpl products=$products} {elseif $smarty.get.id_category == 3} {include file=$tpl_dir./product-list3.tpl products=$products} {/if} Then create product-list2.tpl and product-list3.tpl. I find this solution to be slightly daunting for the developer when the customer wants to create multiple pages full of products. rocky, would you mind providing a solution where the conditional statement is applied somewhere else which also calls a different template file dynamically (by dynamically, I mean there's no need to constantly update the categories' id if there are new pages created)? Maybe apply it to the subcategories and all the subcategories have a different product list template (with its own CSS and JS obviously) or simply call the same product list template but extend the template while hiding the original content? I'll attempt a solution in the meantime, but may not get too far with the dynamic calls. Link to comment Share on other sites More sharing options...
Ulisses Ramos Posted May 3, 2012 Share Posted May 3, 2012 (edited) Smarty if statements to the rescue yet again! Modify header.tpl in your theme's directory and modify the body tag and change it from: <body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}> to: <body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}{if $smarty.get.id_category == 3 OR $smarty.get.id_category == 4 OR $smarty.get.id_category == 5} class="no_columns"{/if}> and the left column code from: <!-- Left --> {$HOOK_LEFT_COLUMN} to: {if $smarty.get.id_category != 3 AND $smarty.get.id_category != 4 AND $smarty.get.id_category != 5} <!-- Left --> {$HOOK_LEFT_COLUMN} {/if} and change the right column section in footer.tpl in your theme's directory from: <!-- Right --> {$HOOK_RIGHT_COLUMN} to: {if $smarty.get.id_category != 3 AND $smarty.get.id_category != 4 AND $smarty.get.id_category != 5} <!-- Right --> {$HOOK_RIGHT_COLUMN} {/if} Then add the following to global.css to increase the width of the center column when the left and right columns are missing: body.no_columns #center_column { width: 960px; } Change 960px to whatever width is appropriate. Thank you very much. with your tip i was able to solve my problem by replacing id_category with id_cms and is working like a charm Thank you Edited May 3, 2012 by oriflameorge (see edit history) Link to comment Share on other sites More sharing options...
zachlurie354 Posted December 30, 2012 Share Posted December 30, 2012 This is probably a simple question, but how about if I still want to retain a right column, just ditch the left column? Is it simply down to how wide I call the center block? Link to comment Share on other sites More sharing options...
Recommended Posts