Farid Rn
Farid Rn

Reputation: 3207

Joomla - Check to see if we are in admin area or not

I'm creating a new template for my joomla website and I've replaced joomla's native Mootools with jQuery and I'm converting all moo codes to jQuery ones.

Somehow many of codes like the ones in joomla libraries are written for both admin and frontend area, and if I replace them with jquery codes, admin section won't work properly. I wanna know if there's a way to determine if we are in admin section of site or not, so I can use javascript codes based on this condition.

Upvotes: 17

Views: 10079

Answers (2)

Shaz
Shaz

Reputation: 2647

It seems to work in Joomla 1.5, Joomla 2.x and 3.x

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

Upvotes: 36

bato3
bato3

Reputation: 2815

For Joomla 4.0 should be

$app = Joomla\CMS\Factory::getApplication();
if ($app->getName() == 'administrator')   //since   3.2
    echo 'Client is administrator';

Upvotes: 5

Related Questions