Joomla changing menu from Component

Posted by Bobz on Stack Overflow See other posts from Stack Overflow or by Bobz
Published on 2012-09-27T15:36:15Z Indexed on 2012/09/27 15:37 UTC
Read the original article Hit count: 136

Filed under:
|
|

My component is always shown on the Default menu, I want to be able to change the menu from my component.

I have found that:

  • $currentMenuId = JSite::getMenu()->getActive()->id ;

Returns the current active Menu item

However,

  • $menu->setActive( $menuitemid );

Does not do anything,

Whether I use,

  • $app = JFactory::getApplication(); $menu = $app->getMenu(); $menu->setActive( $menuitemid );

or,

  • $menu = JSite::getMenu(); $menu->setActive( $menuitemid );

How can I change the menu?

As I do not want it to always be shown on the default menu.

© Stack Overflow or respective owner

Related posts about joomla

Related posts about menu