2

使用带有 SEF 和 mod rewrite 的 joomla 3.1。
如何获取“菜单项别名”引用的菜单项的链接?
使用下面的代码呈现菜单项别名的别名字段,而不是“菜单别名”目标。

 $menu->getItem($men->id)->route  
4

1 回答 1

0

我认为这不是最好的方法,但是您可以从数据库中加载它,例如...

$menuLink=""; //to be used to store the result of our query
$alias='somealias'; //I am guessing you will already have the alias ready from some source

//query the database to find the link corresponding to this alias
$db=JFactory::getDbo();
$query=$db->getQuery(true);
$query->select('link');
$query->from('#__menu');
$query->where("alias='" . $alias . "'");
$db->setQuery($query);
try
{
    $result=$db->loadObject();
    $menuLink=$result->link;
}
catch(RuntimeException $e)
{
    JError::raiseError(500, $e->getMessage());
}

如果有人想出更好的方法,那也很好:) 这就是我通常的做法,但对我来说效果很好。希望这可以帮助。

于 2014-05-08T07:40:19.950 回答