Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.4k views
in Technique[技术] by (71.8m points)

php - Joomla : how to get the url of a specific Menu itemID?

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

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

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

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

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.

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.

Kindly help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...