I have a shop setup using J2Store, which sets up products as articles. On the main layout I use the Category Blog layout.

I have customised the addtocart.php file to add a View Product Information button. This button takes the user to the article page.

The issue is that on the article page the same addtocart.php file is used. So I would like a way to only show the button if I am on the category blog layout. Is there a way I can determine what page/layout I am on wether to show the button or not?

1 Answer 1


You're going to want to use JInput for this.

$jinput = JFactory::getApplication()->input;

$option = $jinput->getCmd('option'); // This gets the component
$view   = $jinput->getCmd('view');   // This gets the view
$layout = $jinput->getCmd('layout'); // This gets the view's layout

if ($option == 'com_content' && $view == 'category' && $layout == 'blog')
    // Show your button here
  • Spot on, thank you!
    – StuartM
    Commented Mar 11, 2015 at 23:37
  • Thanks for the answer. This however does not work for the view and layout if there pagination is used. If you go to a next page (e.g. page 2), the $view = $jinput->getCmd('view') return nothing. Is this a bug in Joomla or is there another way to get these variables?
    – Roy Haanen
    Commented Jan 27, 2016 at 12:59

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.