在Joomla 2.5中,基于文章ID,如何以编程方式查找已分配此文章的相关菜单项?
提前致谢。
答案 0 :(得分:0)
$db =& JFactory::getDBO();
$query = $db->getQuery(true);
$query->SELECT('
menu.id AS id
,menu.link AS link');
$query->FROM('#__menu AS menu');
$query->GROUP('
menu.id
,menu.link');
$db->setQuery($query);
$results = $db->loadAssocList();
//take the results, loop, explode the link apart to isolate the article id
foreach ($results as &$result) {
$articleid = explode('view=article&id=', $result[link]);
echo $result[id] . " - " . $articleid[1] . "<br />";
}