| API | Package | Subpackage | Class | Method | Reference | Last reviewed | Doc status |
|---|---|---|---|---|---|---|---|
Home |
Joomla.Framework |
Application |
JMenu |
getInstance |
getInstance() |
Never | Work in Progress |
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.
JMenu &getInstance ($client, $options = array())
| $client | string | A string identifying the client (see JApplicationHelper::getClientInfo) |
| $options | array | Optional. An associative array of options (reserved for future use) |
Example
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