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?

4 Answers 4


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


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

  • 2
    JRequest::getVar() is deprecated. Use JFactory::getApplication()->input->get('option', '');.
    – Farahmand
    Commented Aug 25, 2014 at 19:04

Another approach is through the JRouter object:


Unsure if there is ever a practical difference between the JRouter value and the value returned through JInput.


Why not use this?


  • Welcome to JSE and thank you for contributing. Your post has been automatically flagged by the system as being potentially low-quality. When you have insights to offer, please post them with the intent to educate and empower the OP and researchers. Your answer effectively drops a function call on this page and nothing more. Please go to a bit more effort to explain how/why your advice works and/or why your advice is better than a pre-existing answer. If there are any known caveats to your advice, please add them too. Please take our tour, then edit your answer. Thanks again. Commented Nov 22, 2020 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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