Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to set up my template so it will display different layout depending on what component is being used on current page. How to check for this?

share|improve this question
up vote 10 down vote accepted

For Joomla 3.x

While the code from the other answer will work, JRequest is deprecated, therefore you should use the following:

$jinput = JFactory::getApplication()->input;
echo $jinput->get('option');

For example, if you are displaying an Article and use the above code, it will output com_content

share|improve this answer

For Joomla 2.5

We can check by getting the URL parameters, using the JRequest::getVar() method and check for the option parameter.

jimport( 'joomla.environment.request' );
echo JRequest::getVar('option', '')

JRequest API Documentation

share|improve this answer
JRequest::getVar() is deprecated. Use JFactory::getApplication()->input->get('option', '');. – Farahmand Aug 25 '14 at 19:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.