We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Modifying control panel menus

Development and Programming

Jack Scott's avatar
Jack Scott
18 posts
16 years ago
Jack Scott's avatar Jack Scott

I’m building a web app in EE2 that’ll require a number of custom modules. I’d like to add links for these modules to the control panel’s top menu so they can be easily accessed by users. Is there a way to programmatically add menu items when modules or other addons are installed? Is such a function planned for future versions?

I’ve looked into using quick tabs for this function, but I don’t think it’ll work well with my application. The app will have thousands of users spread across several user groups when it goes into production; I think security requirements will make manipulating tabs difficult.

If needed, I can implement this function through a custom module; all I need is an extension hook added to the Menu library. Is there a procedure for requesting an extension hook?

(I’m pretty sure I asked this question a few months ago. That was probably during the private beta, and I don’t think those messages are searchable anymore.)

Thanks for your help, Jack

       
Ingmar's avatar
Ingmar
29,245 posts
16 years ago
Ingmar's avatar Ingmar
I’d like to add links for these modules to the control panel’s top menu so they can be easily accessed by users. Is there a way to programmatically add menu items when modules or other addons are installed?

Take a look at the Layout Class docs.

       
Jack Scott's avatar
Jack Scott
18 posts
16 years ago
Jack Scott's avatar Jack Scott

The layout class appears to control the content tabs for publish and edit pages. I need to modify the control panel’s main navigation menu, controlled by the Menu class in expressionengine/libraries/Menu.php. Are there any plans on making the main navigation menu customizable?

Thanks, Jack

       
Adam Dorsey's avatar
Adam Dorsey
1,439 posts
16 years ago
Adam Dorsey's avatar Adam Dorsey

I’ll have to check with the team on this one. I will update this thread when I hear something.

Thanks!

       
Bjørn Børresen's avatar
Bjørn Børresen
629 posts
16 years ago
Bjørn Børresen's avatar Bjørn Børresen

If it doesn’t exist, it’s a great feature request.

It’d be awesome to be able to add e.g. a menu item called “View customers” to the “Members” menu for instance.

subscribing to thread

       
Jack Scott's avatar
Jack Scott
18 posts
16 years ago
Jack Scott's avatar Jack Scott

All I really need is the ability to add two or three top-level menu tabs, each with a handful of submenus. I think I can add this capability with a well placed extension hook. I do like Bjorn’s idea of adding submenus to existing tabs.

       
Jack Scott's avatar
Jack Scott
18 posts
16 years ago
Jack Scott's avatar Jack Scott

I have a prototype control panel menu extension working. It adds menus to the control panel top-of-page menu bar, inserting them between the standard EE menus and quicktabs. The extension requires an extension hook added to expressionengine/libraries/Menu.php. Near line 259, change:

// Main menu, custom tabs, help link - in that order
$menu_string  = $this->_process_menu($menu);
$menu_string .= $this->_process_menu($this->_fetch_quick_tabs(), 0, FALSE);
$menu_string .= $this->_process_menu(array('help' => $this->generate_help_link()));

to:

// Main menu, custom menu, custom tabs, help link - in that order
$menu_string  = $this->_process_menu($menu);
$custom_menu = $this->EE->extensions->call('cp_menu_add_tabs');
if (is_array($custom_menu))
{
    $menu_string .= $this->_process_menu($custom_menu, 0, FALSE);
}
$menu_string .= $this->_process_menu($this->_fetch_quick_tabs(), 0, FALSE);
$menu_string .= $this->_process_menu(array('help' => $this->generate_help_link()));

Once the hook is in place, adding a set of custom menu tabs becomes a simple matter of creating an extension that generates a menu array.

Can we add this extension hook to the EE2 codebase?

       
Bjørn Børresen's avatar
Bjørn Børresen
629 posts
16 years ago
Bjørn Børresen's avatar Bjørn Børresen

Yeah, I second that, having this possibility would be awesome.

       
Jack Scott's avatar
Jack Scott
18 posts
16 years ago
Jack Scott's avatar Jack Scott

While building my monster EE2 Web App, I ran into a situation where I had to rewrite the control panel menus instead of merely adding new tabs. I added a second extension hook to Menu.php that allows modification of the $menu array, similar to how the sessions_end hook allows modifications to the Sessions object.

In expressionengine/libraries/Menu.php, near line 259, change:

// Main menu, custom tabs, help link - in that order
$menu_string  = $this->_process_menu($menu);
$menu_string .= $this->_process_menu($this->_fetch_quick_tabs(), 0, FALSE);
$menu_string .= $this->_process_menu(array('help' => $this->generate_help_link()));

to

// Main menu, custom tabs, help link - in that order
$this->EE->extensions->universal_call('cp_menu_rewrite_tabs', $menu);
$menu_string  = $this->_process_menu($menu);
$menu_string .= $this->_process_menu($this->_fetch_quick_tabs(), 0, FALSE);
$menu_string .= $this->_process_menu(array('help' => $this->generate_help_link()));

This extension hook provides much more flexibility than the one I submitted previously in this thread. It allows an extension to add menu items to the existing menu, change menu items or remove them completely. Please consider adding this extension hook to future versions of Expression Engine.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.