Joomla:如何获取特定菜单项 ID 的 url?

2022-01-06 00:00:00 url php menu joomla

朋友一个新手问题.........我需要帮助来获取特定菜单项 ID 的 URL.情况是这样的:

Friends a newbie question.........I need help in getting the URL of a specific Menu itemID. The situation is like this:

我正在运行 Joomla 并要求用户输入菜单 ID 并为该菜单 ID 选择布局.

I am running Joomla and asking for a user to input for a menu ID and choose a layout for that menu ID.

我想用 Menu itemID 的这个 URL 做一些其他的事情.

I want to do something else with this URL of the Menu itemID.

如何获取用户提供的这个Menu itemID的URL?

How can I get the URL of this Menu itemID provided by the user?

例如,如果用户输入是liek $this->get ('menulayoutid'>; 并且他输入和ID 54 那么我如何得到菜单 ID 54 的 URL.

For Example if the user input is liek $this->get ('menulayoutid'>; and he inputs and ID of 54 then how do I get the URL for Menu ID 54.

请注意:我想从我的 PHP 文件中而不是在浏览器中获取此 URL,以便我可以将该 URL 的值用于其他目的.

Please note: I want to get this URL from within my PHP file and not in the browser so that I can use the value of that URL for some other purpose.

请帮忙.

推荐答案

$itemid = JRequest::getVar('Itemid');
$application = JFactory::getApplication();
$menu = $application->getMenu();
$item = $menu->getItem($itemid);
$link = new JURI($item->link);
$link->setVar('ItemId', $itemid);

来源:http://forum.joomla.org/viewtopic.php?p=1836005

相关文章