Simplified, I have a component with multiple views and a menu setup like the one below.

Home (this is also Joomla default page)



  • Users
  • Settings

Admin > Users is a view using the default,php with display(){...} and o/c a default.xml for the menu item. This view also contains an edit.php form displayed via dispalyEdit(){} called edit.php. This is all rather basic and working fine. However, if the edit form shows, the main menu goes and selects 'HOME', or what ever the Joomla default page is.

How can I keep the main menu selection on 'Admin'? or in general, how to keep the parent selected even if the child view is NOT a menu item itself?

This feels rather simple, but I can't find an answer. It seems pointless to add 'edit' to the menu as it can't be called from the menu. Any pointers?

1 Answer 1


I did something similar to this by building a custom layout for Menu module and put it in my template.

The path to this layout looks like this: templates/your_template/html/mod_menu/your_custom_layout.php

The original layout is here: modules/mod_menu/tmpl/default.php

Copy the code of default.php and put into your_custom_layout.php and customize it.

In my cases, I did some if-else to check what page user was on then added "active" CSS class to the parent menu item. In your case you can make your Admin menu item "active" (selected) and remove "active" (selected) state from your Home menu item.

In short it is just about adding/removing CSS class for active/selected menu item. What class to add/remove depends on your template.

Another method is use setActive() function, but I haven't used it yet so I'm not really sure how it works. This is sample code:

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

$menuItemId is the ID of the menu item you want to set active/selected, it is Admin in your example. You can see how it is used in libraries/cms/router/site.php.

  • Thank. I ended up using some js to select the menu I wanted. But Maybe using ->setActive is the better way. Just needs some extra code to find the 'tagt' menuId
    – Andreas
    Jun 7, 2015 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.