How to determine where from your script is invoked.

How to determine where from your script is invoked. On the back end or the front end.

$app = JFactory::getApplication();
if($app->isAdmin()) echo 'ADMIN PART DETECTED';

 

Other J! helpfull functions (isAdmin(), isSite(),isWinOS()) :

/**
 * Is admin interface?
 *
 * @return  boolean  True if this application is administrator.
 *
 * @since   11.1
 */
public function isAdmin()
{
	return ($this->_clientId == 1);
}

/**
 * Is site interface?
 *
 * @return  boolean  True if this application is site.
 *
 * @since   11.1
 */
public function isSite()
{
	return ($this->_clientId == 0);
}

/**
 * Method to determine if the host OS is  Windows
 *
 * @return  boolean  True if Windows OS
 *
 * @since   11.1
 */
public static function isWinOS()
{
	return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
}

Scroll to Top
Ads: