Thursday 27 November 2014

To add the submenu on Left Sidebar on custom component in Joomla 3.x.x

In latest version of Joomla (3.3.6+), if you are looking to find a way out to add new menu/navigation on the left sidebar list within Administrative view (of your custom component or existing component), please follow as below;

In fact, you can do from two places based on your requirement.
  1. First, if you just need to show under one particular submenu link, then please add on  administrator/components/com_yourcomponent/views/photos/view.html.php, within the display() function. But, make sure you are calling the addEntry() function before the JHTMLSidebar::render().
    // To fine all the entries currently exist on the Submenu List
    $menu_entries = JHtmlSidebar::getEntries();*/
    //print_r($menu_entries);
    
    
    // To add new menu item to submenu on the Left Sidebar
    JHtmlSidebar::addEntry('Configuration', 'index.php?option=com_yourcomponent&view=photos&layout=configuration'); // NameOfMenu, URL_Of_The_Menu
    JHtmlSidebar::addEntry('Export', 'index.php?option=com_yourcomponent&view=photos&layout=export');
    
    // Show sidebar
    $this->sidebar = JHtmlSidebar::render();
    

  2. Or you can directly add within the administrator/components/com_yourcomponent/yourcomponent.php file as below;
    // import joomla controller library
    jimport('joomla.application.component.controller');
    
    // To add new menu item to submenu on the Left Sidebar
    JHtmlSidebar::addEntry('Configuration', 'your_url'); 
    JHtmlSidebar::addEntry('Export', 'your_url');
    
    
    

No comments:

Post a Comment

Please post any queries and comments here.