yaniv14 Posted April 4, 2013 Share Posted April 4, 2013 (edited) Hi, I am trying to get the top horizontal menu to show only 1 level of sub category even if I have more sub-levels, but with no luck so far. Something like block categories has (comes with that option in back office configuration). Any help will be appreciated. Edited April 9, 2013 by yaniv14 (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted April 6, 2013 Share Posted April 6, 2013 Hi Yani(v?) I would have a look at the following two functions in the file: /modules/blocktopmenu/blocktopmenu.php private function getCategoryOption($id_category = 1, $id_lang = false, $id_shop = false, $recursive = true) and private function getCategory($id_category, $id_lang = false, $id_shop = false) Probably have to make some 'depth' counter that you give to the recursive function. Have a look. My 2 cents, Pascal Link to comment Share on other sites More sharing options...
yaniv14 Posted April 7, 2013 Author Share Posted April 7, 2013 Hi Pascal, Thank you for replying, but I am still unable to solve it. Can you give me a hand on this one. Yaniv M Link to comment Share on other sites More sharing options...
PascalVG Posted April 8, 2013 Share Posted April 8, 2013 (edited) Hi Yaniv, override modules/blocktopmenu/blocktopmenu.php i.e. copy this file to /themes/<your themefolder="">/modules/blocktopmenu/blocktopmenu.php</your> then find the function getCategory() at the end of this function, add a little code (red lines): (Sorry, code layout is messed up) if (count($children)) { if ($category->level_depth <= 1) // 1 is level you still want to show { $this->_menu .= '<ul>'; foreach ($children as $child) $this->getCategory((int)$child['id_category'], (int)$id_lang, (int)$child['id_shop']); $this->_menu .= '</ul>'; } } $this->_menu .= '</li>'; This should do the trick. Hope this helps, Pascal Edited April 8, 2013 by PascalVG (see edit history) 5 Link to comment Share on other sites More sharing options...
yaniv14 Posted April 9, 2013 Author Share Posted April 9, 2013 Thank you Pascal, I own you one. Link to comment Share on other sites More sharing options...
PascalVG Posted April 10, 2013 Share Posted April 10, 2013 My pleasure :-) I learn from it myself every day, so thanks for asking :-) Pascal 1 Link to comment Share on other sites More sharing options...
Petru Posted August 2, 2013 Share Posted August 2, 2013 Thanks Pascal, you saved my day. 1 Link to comment Share on other sites More sharing options...
mediabeast Posted September 2, 2013 Share Posted September 2, 2013 Thanks Pascal. Link to comment Share on other sites More sharing options...
creacion Posted January 30, 2014 Share Posted January 30, 2014 (edited) Hi Yaniv, override modules/blocktopmenu/blocktopmenu.php i.e. copy this file to /themes/<your themefolder="">/modules/blocktopmenu/blocktopmenu.php</your> then find the function getCategory() at the end of this function, add a little code (red lines): (Sorry, code layout is messed up) if (count($children)) { if ($categorie->level_depth <= 1) // 1 is level you still want to show { $this->_menu .= '<ul>'; foreach ($children as $child) $this->getCategory((int)$child['id_category'], (int)$id_lang, (int)$child['id_shop']); $this->_menu .= '</ul>'; } } $this->_menu .= '</li>'; This should do the trick. Hope this helps, Pascal The name of the variable is $categorie, not $category. Aslo, you cannot override a module’s PHP so you have to edit the module code directly. Just changing that it works perfect! Edited January 30, 2014 by creacion (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted January 31, 2014 Share Posted January 31, 2014 Hi Creacion, Interesting, in my file I have $category and $categories, but no $categorie. do you have a french version of the file somehow? Anyway, anyone who needs this, check if you have one of the two variables and use that one. thanks, creacion! pascal Link to comment Share on other sites More sharing options...
ginotoffoli Posted February 13, 2014 Share Posted February 13, 2014 Yaniv, you are the man!! Link to comment Share on other sites More sharing options...
Ron morales Posted May 15, 2014 Share Posted May 15, 2014 (edited) Hi Creacion, Interesting, in my file I have $category and $categories, but no $categorie. do you have a french version of the file somehow? Anyway, anyone who needs this, check if you have one of the two variables and use that one. thanks, creacion! pascal how to show sub-categories with click in buton? in ps 1.6? 1 picture, 2 picture its my web work with hover css but navegation mobile its bad Edited May 15, 2014 by Ron morales (see edit history) Link to comment Share on other sites More sharing options...
Ron morales Posted May 20, 2014 Share Posted May 20, 2014 Solved with a module 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