Duboe Posted July 16, 2017 Share Posted July 16, 2017 (edited) The goal is quite simple: Only expand the current category. Problem: I overwrite the module-file ps_categorytree.tpl in the theme. {if $node.id==$category.id_parent || $node.id==$category.id} That works as is, but I ran into a problem. I have another module that adds an extra node at the end of the categories. Shop Cat 1 + (signals that there are sub categories) Cat 2 + Cat 3 Cat from Module When I click on the "Cat from Module" smarty breaks on the first + Shop Cat 1 (it breaks here because it has no an issue with $category.id_parent)When I use an extra isset($category) in the if above it makes no difference and an isset($category.id_parent) throws an internal error... Any suggestions? Edited July 16, 2017 by Duboe (see edit history) 1 Link to comment Share on other sites More sharing options...
Duboe Posted July 16, 2017 Author Share Posted July 16, 2017 (edited) {if !$category->id && ($node.id==$category.id_parent || $node.id==$category.id)} If anyone needs this - not the most elegant solution but it works. At least with one sub category. A little more context: (If you don't know where to add this line) If not already there create a folder named 'ps_categorytree' in your_theme -> modules folder. Now create the folders as follows views -> templates -> hook Go to your root modules folder -> modules -> ps_categorytree follow the path above and copy the ps_categorytree.tpl into your created hook folder. Now add / replace after {if $node.children} till {categories nodes=$node.children depth=$depth+1} (not included in the replace) {if !$category->id && ($node.id==$category.id_parent || $node.id==$category.id)} <div class="navbar-toggler collapse-icons" data-toggle="collapse" data-target="#exCollapsingNavbar{$node.id}" aria-expanded="true"> <i class="material-icons add"></i> <i class="material-icons remove"></i> </div> <div class="collapse in" id="exCollapsingNavbar{$node.id}"> {else} <div class="navbar-toggler collapse-icons" data-toggle="collapse" data-target="#exCollapsingNavbar{$node.id}" aria-expanded="false"> <i class="material-icons add"></i> <i class="material-icons remove"></i> </div> <div class="collapse" id="exCollapsingNavbar{$node.id}"> {/if} and you are done. Parent categories should now expand if you are in a sub category. Edited July 16, 2017 by Duboe (see edit history) Link to comment Share on other sites More sharing options...
schot Posted October 12, 2017 Share Posted October 12, 2017 We've got it but the names of the subcategory doesn't show up! You can see it here: http://dev.allinpreventie.nl/index.php?id_category=21&controller=category We need help! PLEASE! Link to comment Share on other sites More sharing options...
ENS Enterprises Posted October 13, 2017 Share Posted October 13, 2017 Hi, It seems it is not able to fetch the subcategory. Can you please let me know the changes which you have done. Thanks, Link to comment Share on other sites More sharing options...
schot Posted October 13, 2017 Share Posted October 13, 2017 I have copied this code: {if !$category->id && ($node.id==$category.id_parent || $node.id==$category.id)} <div class="navbar-toggler collapse-icons" data-toggle="collapse" data-target="#exCollapsingNavbar{$node.id}" aria-expanded="true"><i class="material-icons add">xE145;</i><i class="material-icons remove">xE15B;</i></div><div class="collapse in" id="exCollapsingNavbar{$node.id}">{else}<div class="navbar-toggler collapse-icons" data-toggle="collapse" data-target="#exCollapsingNavbar{$node.id}" aria-expanded="false"><i class="material-icons add">xE145;</i><i class="material-icons remove">xE15B;</i></div><div class="collapse" id="exCollapsingNavbar{$node.id}">{/if} And paste it as they said. That is the only change I've made. What can I do about this? Thank you! Link to comment Share on other sites More sharing options...
schot Posted October 16, 2017 Share Posted October 16, 2017 Hi there, Maybe I forgot something. It is working but I still don't see the names of the subcategories. Can you please help me? Thank you very much! Link to comment Share on other sites More sharing options...
tantan199 Posted November 9, 2017 Share Posted November 9, 2017 Hi, I just create a tutorial about how to set the category tree links module to expand the current brunch. http://www.sunnytoo.com/8222/how-to-set-the-category-tree-links-module-to-expand-the-brunch-containing-current-category-in-prestashop-1-7 Regards Link to comment Share on other sites More sharing options...
BenW Posted April 26, 2022 Share Posted April 26, 2022 Hi there, Sorry for waking up this thread from the grave, but prestashop files changed quite a lot with the newest versions. Does someone know how to do it on the new versions ? Thanks heaps. 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