skulaluks Posted August 30, 2010 Share Posted August 30, 2010 Hi,Is there a possibility to have the category tree pre-opened just to its first level?I played with the sourcecode related to this topic that is here:\themes\prestashop\js\tools\treeManagement.js\modules\blockcategories\category-tree-branch.tplbut i didn't do anything generally usable.Can anyone help? Link to comment Share on other sites More sharing options...
rocky Posted August 30, 2010 Share Posted August 30, 2010 Give the category you want to expand an ID like "default", then use code like the following to expand it by default: <script type="text/javascript"> openBranch($('ul.tree.dhtml li.default'), true); <script> Change true to false if you don't want the animation. Link to comment Share on other sites More sharing options...
skulaluks Posted August 30, 2010 Author Share Posted August 30, 2010 Where can I assign the IDs of the categories of the tree that i want to have open by default? i would make some changes in the line 37 or 38 of the \js\tools\treeManagement.js where is executed the code during the pageload, but i dont know what. //collapse every expanded branch $('ul.tree.dhtml span.grower.OPEN').addClass('CLOSE').removeClass('OPEN').parent().find('ul:first').hide(); $('ul.tree.dhtml').show(); Link to comment Share on other sites More sharing options...
rocky Posted August 31, 2010 Share Posted August 31, 2010 To add an ID to the categories, change line 1 of modules/blockcategories/category-tree-branch.tpl from: <li {if isset($last) && $last == 'true'}class="last"{/if}> to: <li id="cat{$node.id}" {if isset($last) && $last == 'true'}class="last"{/if}> 1 Link to comment Share on other sites More sharing options...
skulaluks Posted September 1, 2010 Author Share Posted September 1, 2010 Hi that is what i wanted, but it still doesnt work properly.The only problem is that it works only for one category (The 1st one on the 0th level).the second one is not opened. I tried to call the javasctipt twice for more 0th level categories, but it always worked only for the first one: openBranch($('ul.tree.dhtml li#cat98'), true); openBranch($('ul.tree.dhtml li#cat99'), true); //mark this 'ul.tree' elements as already 'dynamized' this bahaved same: toggleBranch($('ul.tree.dhtml li#cat98')); toggleBranch($('ul.tree.dhtml li#cat99')); //mark this 'ul.tree' elements as already 'dynamized' Link to comment Share on other sites More sharing options...
skulaluks Posted September 2, 2010 Author Share Posted September 2, 2010 I already tried many combination, byt it seems that the tree can have only one category preopened. Link to comment Share on other sites More sharing options...
skulaluks Posted September 12, 2010 Author Share Posted September 12, 2010 Please help, it doesnt work.All my tree branches have assigned ids of their categories(eg. )I tried to open the branch by calling javascript from firebug console, but openBranch($('ul.tree.dhtml li#cat98'), true); doesnt work at all.Can anyone please tell me what script should be call to open the branch?Thank you Link to comment Share on other sites More sharing options...
vasikgreif Posted October 1, 2010 Share Posted October 1, 2010 Same here, the code does open the first category only... Any ideas what to do? Thanks Link to comment Share on other sites More sharing options...
skulaluks Posted October 12, 2010 Author Share Posted October 12, 2010 (edited) solved! 1. add an ID to the categories, change line 1 of modules/blockcategories/category-tree-branch.tpl to: <li id="cat{$node.id}" {if isset($last) && $last == 'true'}class="last"{/if}> to tag each branch with its own id. 2. add following javascript in the js/tools/treeManagement.js before the closing bracket} of the $(document).ready(function () function: if (window.location.pathname=='/') { setTimeout("$('#cat99').children('span.grower').trigger('click')",500); setTimeout("$('#cat98').children('span.grower').trigger('click')",1000); } in my case it preopens category 99 and 98 with tiny delay of half of a second. Edited May 19, 2012 by rocky Added missing code (see edit history) Link to comment Share on other sites More sharing options...
skulaluks Posted October 12, 2010 Author Share Posted October 12, 2010 oh, here in this forum is some hacker censoring script that rewrote part of the solution code:instead of [removed] use vindow.location with w Link to comment Share on other sites More sharing options...
vasikgreif Posted October 14, 2010 Share Posted October 14, 2010 Thanks, works like a charm! I have one more problem with this solution though. I would need to have the tree opened into one sublevel on all pages. I tried to delete the if ([removed].pathname=='/'), which makes the opening work on all pages, but it closes the branch where the sublevel is selected... Any ideas how to fix this? Link to comment Share on other sites More sharing options...
George K. Posted October 28, 2010 Share Posted October 28, 2010 does not work! i dont know why Link to comment Share on other sites More sharing options...
Artx Posted November 7, 2010 Share Posted November 7, 2010 Read carefuly, everything`s written. I can`t stand people has a problem and solution need`s to be feeded right in mouth.And thank you Skulaluks, helped me too. Link to comment Share on other sites More sharing options...
navlaca Posted August 1, 2011 Share Posted August 1, 2011 Hello Rocky, I am very much interested by the solution of this query but unfortunatelly the code of your reply does not show on this topic (the text is hidden - problem may be linked to the upgrade of the forum). Could you please give me the solution. Thank you very much in advance. Link to comment Share on other sites More sharing options...
vivek tripathi Posted August 3, 2011 Share Posted August 3, 2011 An another way to show category tree preopend add following code at the top in modules->blockcategorie->blockcategories.tpl <script type="text/javascript"> $(document).ready(function(){ $('.grower').trigger('click') }); </script> 2 Link to comment Share on other sites More sharing options...
tehteh Posted September 18, 2011 Share Posted September 18, 2011 solved! 1. add an ID to the categories, change line 1 of modules/blockcategories/category-tree-branch.tpl to: to tag each branch with its own id. ... There is missing (empty) part about adding an ID to category. Can someone share the code how to do it? Link to comment Share on other sites More sharing options...
Jimmy S Posted October 3, 2011 Share Posted October 3, 2011 Can someone add the missing part in the solution? Link to comment Share on other sites More sharing options...
George K. Posted February 9, 2012 Share Posted February 9, 2012 dose this topc censored by some one >? where is the missing codes? Link to comment Share on other sites More sharing options...
rocky Posted May 19, 2012 Share Posted May 19, 2012 Seems it was lost in the transition to the new forum. I added my code back again. Link to comment Share on other sites More sharing options...
greek_batter Posted May 23, 2012 Share Posted May 23, 2012 Hello and sorry for the incovenience but still we cant see the added code... Link to comment Share on other sites More sharing options...
pecopico Posted August 22, 2012 Share Posted August 22, 2012 ummm gracias, pero mucho más fácil es En el backoffice > módules > bloque de categorias (configurar) y elegir "no dinámico" y poner una profundidad por ejemplo de 10. Ahora la tendrás abierta automáticamente. Link to comment Share on other sites More sharing options...
Sharak Posted November 23, 2012 Share Posted November 23, 2012 (edited) I managed to make this much simpler. Let's say we have 3 levels of categories: Main category Subcategory Sub-subcategory Subcategory Main category ... By default in dynamized mode only main categories are visible and has growers to expand. If you want main categories and subcategories be visible by default and only subcategories to have growers to show sub-subcategories you just need one small change in treeManagement.js (location: /themes/<your_theme>/js/tools/): //add growers to each ul.tree elements $('ul.tree.dhtml ul').prev().before("<span class='grower OPEN'> </span>"); change to: //add growers to each ul.tree elements $('ul.tree.dhtml ul il ul').prev().before("<span class='grower OPEN'> </span>"); Edited March 23, 2013 by Sharak (see edit history) 1 Link to comment Share on other sites More sharing options...
pepe9o Posted June 1, 2013 Share Posted June 1, 2013 solved! 1. add an ID to the categories, change line 1 of modules/blockcategories/category-tree-branch.tpl to: <li id="cat{$node.id}" {if isset($last) && $last == 'true'}class="last"{/if}> to tag each branch with its own id. 2. add following javascript in the js/tools/treeManagement.js before the closing bracket} of the $(document).ready(function () function: if (window.location.pathname=='/') { setTimeout("$('#cat99').children('span.grower').trigger('click')",500); setTimeout("$('#cat98').children('span.grower').trigger('click')",1000); } Hello all, sorry for digging this up. I have a problem with this "if". This one is not working. How can i open this category only on my home page ? Or, if all categories are closed, this one have to be open. Can someone help ? Link to comment Share on other sites More sharing options...
ErikSebastia2 Posted July 12, 2013 Share Posted July 12, 2013 Hi, How I can do to has only one category opened, I mean Colabsible. When you "click" in one category, it open the tree. After, when you click to another category, the previous category tree closes and the new are opened. By default in treemanagement, does not have this function. When you click in one category, it still opened. Thanks Best regards Link to comment Share on other sites More sharing options...
rocky Posted July 12, 2013 Share Posted July 12, 2013 Sounds like you want my free Sliding Accordion Categories module, though it is designed for PrestaShop v1.4.x only. Send me a private message with your email address and I'll send it to you. I have a paid AJAX version that dynamically loads categories and is also designed for PrestaShop v1.4.x. P.S. Woohoo! 10,000th post. Link to comment Share on other sites More sharing options...
ErikSebastia2 Posted July 12, 2013 Share Posted July 12, 2013 (edited) Hi Rocky! Congrat for you 10.000 posts!! Few days ago I send to you an email for the module, but I had to update the shop to 1.5.x and I need this feature in blockcategories module. At this time, I have a shop on 1.4.9 with your module Sliding Accordion Categories. It's great module, but I have 2 problems with it: incompatibility with 1.5 and problems with old version of IE (7 and 6). For this reason, I modified the blockcategories of PS with the same aparence of the S.A.C. and now the only problem is the opened trees. Thanks Best regards Edited July 12, 2013 by ErikSebastia2 (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted July 12, 2013 Share Posted July 12, 2013 I see. It looks like you'll have to write some JavaScript to .slideUp() all categories before you .slideDown() a category. Unfortunately, I'm focused on writing guides instead of coding at the moment. I'm currently working on writing a guide for how to use phpMyAdmin. Maybe when I write a PrestaShop Development Guide, I'll get back into some programming again. Link to comment Share on other sites More sharing options...
ErikSebastia2 Posted July 12, 2013 Share Posted July 12, 2013 Yes, I need to modify the JavaScript file, treemanagement.js. Someone knows how I had to modify it to do the collabsable option? Thanks Link to comment Share on other sites More sharing options...
ErikSebastia2 Posted July 16, 2013 Share Posted July 16, 2013 Up! Link to comment Share on other sites More sharing options...
richard655 Posted August 27, 2013 Share Posted August 27, 2013 While skulaluks code does work for those of us who don't want a delay nor an animation is is not so great. Change if (window.location.pathname=='/') { setTimeout("$('#cat99').children('span.grower').trigger('click')",500); setTimeout("$('#cat98').children('span.grower').trigger('click')",1000); } to if (window.location.pathname=='/') { // change grower class so you won't have to click twice to close the category $('li#cat2').children('span.grower').addClass('OPEN').removeClass('CLOSE'); //show whatever menu you want $('li#cat2').children('ul').show(); } And you have categories that start open with no delay and with no animation. Link to comment Share on other sites More sharing options...
eduardofk Posted August 30, 2013 Share Posted August 30, 2013 Hello to all, I can´t make this possibly, I want to display the categories preopenned, till the first subcategory and then I want to show (in dynamic mode) the grower in the first subcategory that could display if user want and do click the third and maybe fourth category. Please help me. Thank you in advance Link to comment Share on other sites More sharing options...
ilovekutchi.com Posted February 28, 2014 Share Posted February 28, 2014 (edited) I managed to make this much simpler. Let's say we have 3 levels of categories: Main category Subcategory Sub-subcategory Subcategory Main category ...By default in dynamized mode only main categories are visible and has growers to expand. If you want main categories and subcategories be visible by default and only subcategories to have growers to show sub-subcategories you just need one small change in treeManagement.js (location: /themes/<your_theme>/js/tools/): //add growers to each ul.tree elements $('ul.tree.dhtml ul').prev().before("<span class='grower OPEN'> </span>");change to: //add growers to each ul.tree elements $('ul.tree.dhtml ul il ul').prev().before("<span class='grower OPEN'> </span>"); Thank you Sharak!! I could finally get it working in PS 1.5.6.2! PS: however, your code has a typo: it should be "...ul li ul..." instead of "...ul il ul..." Edited February 28, 2014 by ilovekutchi.com (see edit history) Link to comment Share on other sites More sharing options...
alano3city Posted September 29, 2015 Share Posted September 29, 2015 how to add class on page load to category which has expandable subcategories? i would like to highglight it by bolding. 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