Joomla Get menu id from names

182 views Asked by At

I am in joomla 2.5 and I try to get the id of a menu, I have the name, the alias

exemple :

menu = FAQ-> menu item =FAQ

I have try :

$app         = JFactory::getApplication('site');
$params      = $app->getParams();
$idfaq       = $params->get('content_id_faq');

but i am a newbie so I dont even know if content_id_faq is correct

thanks

2

There are 2 answers

0
dhh On BEST ANSWER

Have a look at here for more information on how to get the correct item.

0
Elin On

There is no guarantee that either the menu item alias or the article alias must be unique within either the #__menu or #__content table, they just need to be unique within that menu-parent item branch or the category, respectively. Since you are making something custom for a specific site you could modify the queries in the other answer to reflect this; I would do that rather than assuming no one in the future is ever going to use the same aliases. Of course you could write a plugin to basically make those aliases reserved words. Also in your code I would force that to cache so you aren't constantly doing that query.