Joomla:如何获取特定菜单项 ID 的 url? [英] Joomla : how to get the url of a specific Menu itemID?

查看:21
本文介绍了Joomla:如何获取特定菜单项 ID 的 url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友一个新手问题.........我需要帮助来获取特定菜单项 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

这篇关于Joomla:如何获取特定菜单项 ID 的 url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆