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
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.
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
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?
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.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.