JFactory/getApplication

From Joomla! Documentation

Jump to: navigation, search

Returns a reference to the global application object, only creating it if it doesn't already exist. The object returned will be of type JApplication.

Syntax

object JApplication getApplication( $client, $attribs, $prefix )

where:

Argument Data type Description Default
$client string Name by which the application client will be known. For example, Joomla is distributed with three application clients: 'site', 'administrator' and 'installation'. null
$attribs array Associative array of attributes to be passed to the application. array()
$prefix string Prefix to be added to the client name to form the class name for the application. 'J'

Example

This method is most often used to get a reference to the global application object, in which case it can be called with no arguments. In this example, the application object is obtained so that a test can be made to see if the code is running on the front-end (client is 'site') or the back-end (client is 'administrator').

$app =& JFactory::getApplication();
if ($app->isSite())  echo 'Client is site';
if ($app->isAdmin()) echo 'Client is administrator';

See also

Personal tools