Actions

API16

JMenu/getInstance

From Joomla! Documentation

< API16:JMenu
Revision as of 17:37, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Returns a JMenu object

[Edit Descripton]

Description:JMenu/getInstance

Syntax

static getInstance($client, $options=array())
Parameter Name Default Value Description
$client The name of the client
$options array() An associative array of options

Returns

A menu object. 

Defined in

libraries/joomla/application/menu.php

Importing

jimport( 'joomla.application.menu' );

Source Body

public static function getInstance($client, $options = array())
{
        static $instances;
 
        if (!isset($instances)) {
                $instances = array();
        }
 
        if (empty($instances[$client])) {
                //Load the router object
                $info = &JApplicationHelper::getClientInfo($client, true);
 
                $path = $info->path.'/includes/menu.php';
                if (file_exists($path)) {
                        require_once $path;
 
                        // Create a JPathway object
                        $classname = 'JMenu'.ucfirst($client);
                        $instance = new $classname($options);
                } else {
                        //$error = JError::raiseError(500, 'Unable to load menu: '.$client);
                        $error = null; //Jinx : need to fix this
                        return $error;
                }
 
                $instances[$client] = & $instance;
        }
 
        return $instances[$client];
}

[Edit See Also] SeeAlso:JMenu/getInstance

Examples

<CodeExamplesForm />