How to get menu item id if url rewriting is enabled in joomla 3

Can anyone inform me that if url rewriting is included in joomla and the generated url is seo-friendly url, then in this case I can get the id of the menu item, if so what are the steps to get it.

for example my seo friendly url is www.example.com/store

I want to get the ID of a menu item from this url.

+3


source to share


3 answers


To get the whole variable

 $Itemid = JRequest::getVar('Itemid');

      



To get an active menu

$app = JFactory::getApplication();
$menu = $app->getMenu()->getActive()->id;
echo $menu;

      

+4


source


JRequest

loses Joomla 3

. Therefore, you should use the following instead:



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

      

+3


source


The easiest way: $ menu = & JSite :: getMenu (); $ Itemid = $ menu-> getActive () → id;

0


source







All Articles