adeep Posted June 5, 2013 Share Posted June 5, 2013 Hi! I want to give to change the lookout of my shop for every cagtegory by giving each category an own template. Is it possible and what have I to do? Thanks for your help Link to comment Share on other sites More sharing options...
vekia Posted June 5, 2013 Share Posted June 5, 2013 if you want to change only css styles - it is possbile with simple smarty changes + css modification, and it's easy to achieve. BUT everything depends on what you exactly expect. Only category listing? Or maybe products too? Only css? or maybe also layout change? Link to comment Share on other sites More sharing options...
adeep Posted June 6, 2013 Author Share Posted June 6, 2013 thanks for quick answer. I want to give for each category a new layout for products Link to comment Share on other sites More sharing options...
vekia Posted June 6, 2013 Share Posted June 6, 2013 okay, thanks for info what ps version you use? everything depends on it regards Link to comment Share on other sites More sharing options...
adeep Posted June 6, 2013 Author Share Posted June 6, 2013 the latest one, 1.5.4, standard template Link to comment Share on other sites More sharing options...
vekia Posted June 6, 2013 Share Posted June 6, 2013 okay in the controllers/front/ProductController.php you've got something like: $this->context->smarty->assign('errors', $this->errors); $this->setTemplate(_PS_THEME_DIR_.'product.tpl'); add there simple if condition (you can add as many conditions as you want) if ($this->product->id_category_default==4){ $this->setTemplate(_PS_THEME_DIR_.'product-layout-4.tpl'); } else { $this->setTemplate(_PS_THEME_DIR_.'produc.tpl'); } code above means: if the product default category is 4 - then prestashop will use product-layout-4.tpl file to display product if default category will be different - then prestashop will use default product.tpl file now you can create own layout file (located in your theme/YOUR_THEME/ dir) named product-layout-4.tpl Link to comment Share on other sites More sharing options...
adeep Posted June 6, 2013 Author Share Posted June 6, 2013 Great. Thanks for this wonderful help Link to comment Share on other sites More sharing options...
vekia Posted June 6, 2013 Share Posted June 6, 2013 you're welcome btw. if you want to use MANY templates, it's better to use switch php function: switch ($this->product->id_category_default) { case 1: $this->setTemplate(_PS_THEME_DIR_.'product-layout-1.tpl'); break; case 2: $this->setTemplate(_PS_THEME_DIR_.'product-layout-2.tpl'); break; case 3: $this->setTemplate(_PS_THEME_DIR_.'product-layout-3.tpl'); break; default: $this->setTemplate(_PS_THEME_DIR_.'product.tpl'); } it's much better than if conditions, moreover, you can define default value feel free to write if you've got any other questions related to this case regards Link to comment Share on other sites More sharing options...
adeep Posted June 6, 2013 Author Share Posted June 6, 2013 I will try it out and let you know my result. Thanks and have a nice day Link to comment Share on other sites More sharing options...
Recommended Posts