Joomla Application Object

With the JApplicationCMS, you can access many things in Joomla. For example, you can access configuration, input variables, menu or enqueue messages which are shown to the user.

The class files are located at: libraries/src/Application

To get CMS Application object:

$app = JFactory::getApplication();

It is an object of type JApplicationAdministrator or JApplicationSite depending on the application currently running.


1. allowCache

It is used to set or get the cachable state for the response. If the variable $allow is set, then the function sets the cachable state of the response. It always returns the current state.

allowCache(boolean $allow = null)

2. appendBody

It is used to append content to the body content.

appendBody(string $content)

3. enqueueMessage

It enqueues a system message.

enqueueMessage(string $msg, string $type = 'message')

For example,

$app->enqueueMessage('Hello World!');

4. getBody

It returns the body content.

getBody(boolean $asArray = false)

5. getDocument

It is a method to get the application document object.

$doc = $app->getDocument();

6. getHeaders

Method to get the array of response headers to be sent when the response is sent to the client.

$headers = $app->getHeaders();

7. getMenu

It returns the Menu object.

$menu = $app->getMenu();

8. getMessageQueue

It gets the system message queue as array.

getMessageQueue(boolean $clear = false)

9. getPathway

It returns the JPathway object.

getPathway(string $name = null, array $options = array())

10. getRouter

It returns the JRouter object.

getRouter(string $name = null, array $options = array())

11. getSession

It is a method to get the application session object.


12. getTemplate

It gets the name of the current template.

getTemplate(boolean $params = false)

13. isClient

It is used to check the client interface by name. The function returns true if application is of given client type.

For example,

isAdmin = $app->isClient('administrator');
isSite = $app->isClient('site');

14. isHttpsForced

It checks if HTTPS is forced in the client configuration.

15. isSSLConnection

It determine if we are using a secure (SSL) connection.


16. login

Login authentication function.

login(array $credentials, array $options = array())

17. logout

Logout authentication function.

logout(integer $userid = null, array $options = array())

18. prependBody

It prepends content to the body content.

prependBody(string $content)

19. redirect

It is used to redirect to another URL.

redirect(string $url, integer $status = 303)

20. setBody

It sets the body content. If body content already defined, this will replace it.

setBody(string $content)

21. setHeader

It is a method to set a response header. If the replace flag is set then all headers with the given name will be replaced by the new one. The headers are stored in an internal array to be sent when the site is sent to the browser.

setHeader(string $name, string $value, boolean $replace = false)
Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive