Support Joomla!

references:joomla.framework:application:jmenu-getinstance

Table of Contents

getInstance

API Package Subpackage Class Method Reference Last reviewed Doc status
API Home Package Joomla.Framework Subpackage Application Class JMenu Method getInstance Reference 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.

Syntax

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)

Examples

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

 
references/joomla.framework/application/jmenu-getinstance.txt (901 views) · Last modified: 2007/09/22 02:46