Take the 2-minute tour ×
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It's 100% free, no registration required.

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

2 Answers 2

up vote 6 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
    
Oh yes, always there Lodder! –  FFrewin Aug 25 at 19:08

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
1  
JRequest::getVar() is deprecated. Use JFactory::getApplication()->input->get('option', '');. –  Farahmand Aug 25 at 19:04

Your Answer

 
discard

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.