To identify the pages am using the following code

if($menu->getActive()->id == 203){} // some actions

this line returns error in search page. Search url goes like this


when the page loads the following error occurs "Trying to get property of non-object".

2 Answers 2


That's because the $menu->getActive() is not returning an object, and here is because there is no menu item used for the search page.

To get rid of the php notice you are seeing, you could first check if the $menu->getActive() is an object and if yes then get its id property.

like so:

if ( is_object( $menu->getActive() ) ) { 

I think you could use JInput to get the ItemId.

Try using the following:

$jinput = JFactory::getApplication()->input;
$ItemId = $jinput->get('Itemid', '', 'INT');

if ($ItemId == 203)
    // Something here
  • that's a cool solution as well
    – FFrewin
    May 20, 2015 at 7:18

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.