Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the parameter 'site' mean in Joomla getApplication?

Tags:

php

joomla

$a = JFactory::getApplication('site');

I came across this in Joomla API:

static JApplication getApplication ([mixed $id = null], [array $config = array()], [string $prefix = 'J'])

What are the examples of $id, $config and $prefix?

like image 302
Vicheanak Avatar asked Feb 20 '13 10:02

Vicheanak


1 Answers

$id can be 'site' or 'administrator'. If you don't set it, then if you are on the backend, JFactory::getApplication('administrator') will be returned and JFactory::getApplication('site') for the frontend.

Depending on the $id, either /administrator/includes/application.php is included or just includes/application.php.

Using $config you can set the name of the configuration file, session name sessions etc.

Prefix is class name prefix. All core Joomla classes have been prefixed with J, that's why it is the default setting. For example JAdministrator.

Have a look also at http://joomlacode.org/gf/project/joomla/scmsvn/?action=browse&path=/development/tags/1.6.x/1.6.3/libraries/joomla/application/application.php&view=markup for __construct and getInstance methods of JApplication for more details

like image 146
Marko D Avatar answered Sep 30 '22 19:09

Marko D