newuser78 Posted November 24, 2009 Share Posted November 24, 2009 First things first - I started using Prestashop only a few weeks ago and have found it to be really good so kudos to the developers! The shop is coming together nicely with new themes, modules, etc. except for one thing that I can't figure out - either because I am tired or can't find it! How do you get the id_parent when you on a subcategory page (when you are not using the tree thing)?I would like to assign "selected" class to a parent category - this works if you go to a product detail page (product is in a category), e.g.You are in Home > Laptops > Acer > Acer something - then I would like the Laptops button to be highlighted rather than Acer link (subcategory).* Accessories* iphone* iPods* Laptops o Acer o ToshibaAs far as I can see, the issue is the $currentCategoryId variable {if $node.id == $currentCategoryId} class="selected"{/if} Unfortunately, I am struggling to figure out the code in blockcategories.php -particularly line 128 and variable is passed with $smarty->assign('currentCategoryId', intval($_GET['id_category'])); so I guess I need to replace $_GET['id_category'] with something but I just can't figure it out!Many thanks in advance! Link to comment Share on other sites More sharing options...
Radu Posted November 24, 2009 Share Posted November 24, 2009 here is how the path thing works for product page for instance:in product.php you have:'path' => ((isset($category->id) AND $category->id) ? Tools::getFullPath(intval($category->id), $product->name) : Tools::getFullPath(intval($product->id_default_category), $product->name))then check Tools->getFullPath and Tools->getPathyou are able to customize the output in the way you like it Link to comment Share on other sites More sharing options...
newuser78 Posted November 24, 2009 Author Share Posted November 24, 2009 Hi Radumany thanks for your post. I do see the code shown in product.php but how do I use this in modules/blockcategories/blockcategories.php?Thanks again Link to comment Share on other sites More sharing options...
Radu Posted November 24, 2009 Share Posted November 24, 2009 sorry I did not understand your question at first. I am checking now to see how can I help you Link to comment Share on other sites More sharing options...
newuser78 Posted November 24, 2009 Author Share Posted November 24, 2009 No worries Radu - attached is a rough design of the desired effect, I hope this clarifies the situation. Link to comment Share on other sites More sharing options...
newuser78 Posted November 24, 2009 Author Share Posted November 24, 2009 I also attach another rough idea - a "nice-to-have". so basically, I would be happy to keep the following line in blockcategories.php: $smarty->assign('currentCategoryId', intval($_GET['id_category'])); ... and maybe do another line or two just for the purpose of menu styles? e.g. $smarty->assign('parentCategoryId', intval(id_parent_from_database)); I don't know how to in the case of Prestashop unfortunately so any advice, etc. would be greatly appreciated! Link to comment Share on other sites More sharing options...
Radu Posted November 24, 2009 Share Posted November 24, 2009 ok here you go:here is the demo: I won't keep it online for too long in this formhttp://demo.ecommy.com/prestashop/category.php?id_category=41. modules/blockcategories/blockcategories.phpafter: $smarty->assign('currentCategoryId', intval($_GET['id_category'])); add: $currentCategoryId = intval($_GET['id_category']); after: $smarty->assign('currentCategoryId', intval($cookie->last_visited_category)); add: $currentCategoryId = intval($cookie->last_visited_category); above: $smarty->assign('blockCategTree', $blockCategTree); add: $topCategoryId = Category::getTopCategory($currentCategoryId, $resultIds); $smarty->assign('topCategoryId', $topCategoryId); 2. modules/blockcategories/category-tree-branch.tplreplace: {$node.name|escape:htmlall:'UTF-8'} with: {$node.name|escape:htmlall:'UTF-8'} 3. themes/prestashop/css/global.cssreplace: div#categories_block_left ul.tree a.selected{ color: #488c40; font-weight: bold; } with: div#categories_block_left ul.tree a.selected{ font-weight: bold; } div#categories_block_left ul.tree a#selected2{ color: #488c40; font-weight: bold; } 4. themes/prestashop/classes/Category.phpafter: public function updateGroup($list) { $this->cleanGroups(); if ($list AND sizeof($list)) $this->addGroups($list); } add: public function getTopCategory($selected, $cats) { if(intval($cats[$selected]['id_parent']) > 1) { return Category::getTopCategory($cats[$selected]['id_parent'], $cats); } else { return $selected; } } Link to comment Share on other sites More sharing options...
newuser78 Posted November 24, 2009 Author Share Posted November 24, 2009 That does look great - very much appreciated! I shall implement the changes now and give you an update shortly.Once again thanks very much. Link to comment Share on other sites More sharing options...
newuser78 Posted November 24, 2009 Author Share Posted November 24, 2009 Hi RaduJust a quick note to say... THANKS! It works beautifully!There is one slight problem.... http://www.ecommy.com/donation gav me a 404 error. Link to comment Share on other sites More sharing options...
Radu Posted November 24, 2009 Share Posted November 24, 2009 Forgot about that page no need to donate - it was my pleasure helping you. Link to comment Share on other sites More sharing options...
newuser78 Posted November 24, 2009 Author Share Posted November 24, 2009 No worries, Radu - thanks very much for your help. It was very much appreciated - a lifesaver (and saved a few hair follicles!)! I shall definitely contribute whatever I can to this forum too. Link to comment Share on other sites More sharing options...
Guest Posted July 20, 2010 Share Posted July 20, 2010 4. themes/prestashop/classes/Category.php I can't find out this file, where is it please? Link to comment Share on other sites More sharing options...
vero20 Posted June 6, 2012 Share Posted June 6, 2012 Hey this is great, but I'm using PS 1.4 and things look different there. How would it be? 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