mediabunker Posted September 8, 2013 Share Posted September 8, 2013 (edited) Hi, I am using categories that have sub categories such as: 1) Womens 1a) Dresses 1b) Hats 2) Mens 2a) Trousers 2b) Shoes And so on... Now, I want to add the root class to the body eg. '<body class="womens">' but ideally I also want to add the current category too: eg. '<body class="womens hats">'. All of the above is so that I can style women, men etc pages with unique styles. In places I also want to style things uniquely for sub categories too. I have seen that you can use the following: {$category->name} - but this only shows current category {$id_category_parent} - but this is just an id, cannot see a way of translating this into a name In essence, I'm looking at something similar to a breadcrumb but written to a class. I have even looked at breadcrumb.tpl but with limited success. I have spent many hours looking for a solution to this problem but have found no real solution, hope someone can help? I'm using Presta ver. 1.5.5 Thanks, Adam. P.S. I'm also try to get the friendly URL within CMS pages to display, $meta_title displays the normal name but I do not want this. Edited September 10, 2013 by mediabunker (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted September 9, 2013 Share Posted September 9, 2013 Here's what I'd do. I would create a module that hook to the header. From this header hook, I would grab the category id with Tools::getValue('id_category') Then, instantiate a new category object. At this point you can assing the link_rewrite value to a smarty variable, so that you can add the current category's hyphened version of the name as a class. Then, with the same instance use $categoryInstance->getParentsCategories(); to get all its parents. Iterate throught the parents and get the one with id_parent = 0 or 1, or in any case the chils of the root category's id. Grab it's link_rewrite, which should already be there, and assign it as a smarty variable as well Link to comment Share on other sites More sharing options...
mediabunker Posted September 10, 2013 Author Share Posted September 10, 2013 Thanks Nemo 1. Using your information and various other sources online, I have managed to create a simple module that does the job nicely. Link to comment Share on other sites More sharing options...
w3bsolutions Posted May 27, 2014 Share Posted May 27, 2014 Hi! I am looking to do the same... would you mind sharing your solution? Thanks in advance. Link to comment Share on other sites More sharing options...
Recommended Posts