joomla2.5

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.


Solution

  • 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';