references:joomla.framework:application:jmenu-getinstanceTable of Contents
getInstance
Returns a reference to a client’s global JMenu object, only creating it if it doesn’t already exist. JMenu is implemented as a Singleton object, that is only one instance of this object exists per client (’site’, ‘administrator’, ‘installation’.) Do not use the new operator to “create” a new menu; the JMenu instance provides you with all the mainmenu modules. SyntaxJMenu &getInstance ($client, $options = array())
ExamplesExample jimport( 'joomla.application.menu' ); // get the Singleton instance $menu = &JMenu::getInstance('site'); // get the active menu $active = &$menu->getActive(); echo 'Active: ', $active->name; // get the default menu $active = &$menu->getDefault(); echo 'Default: ', $active->name; Might produce: Active: FAQ Default: Home |


