3

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

http://localhost/joomla/component/search/?searchword=destination&searchphrase=all&Itemid=103

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

5

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() ) ) { 
 //... 
}
2

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 '15 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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