Joomla 3.1 - Get active menu item url

2019-02-19 17:54发布

问题:

As soon as I click on the "Media" item in my main menu, the following url is generated:

http://test.local/index.php/media-files

Now, I would like to create a module that is displayed only in media-files. Moreover, I want to retrieve the url of this active menu item.

So my question: How can I get the SEF-URL of an active menu item?

Thanks in advance,

enne

回答1:

I think this might be what you want:

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

echo JRoute::_($menu);

I've tested this as well, so let me know if it's what you require.



标签: joomla