Jump to content

[Solved] Top Horizontal Menu sub category depth = 1


yaniv14

Recommended Posts

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 by yaniv14 (see edit history)
Link to comment
Share on other sites

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

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 by PascalVG (see edit history)
  • Like 5
Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...
  • 4 months later...

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 by creacion (see edit history)
Link to comment
Share on other sites

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

  • 2 weeks later...
  • 3 months later...

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

post-319618-0-89505000-1400171144_thumb.jpg

post-319618-0-13377800-1400171202_thumb.jpg

Edited by Ron morales (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...