簡體   English   中英

如何在Joomla 2.5中以編程方式找到將文章分配給的菜單項?

[英]How to programmatically find a menu item which an article is assigned to in Joomla 2.5?

在Joomla 2.5中,如何基於商品ID來以編程方式找到已分配給該商品的相關菜單項?

提前致謝。

嗯...可能會變得凌亂。 除非有一個更簡單的解決方案,否則類似的內容將幫助您入門(經過測試並且可以正常工作):

$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 />";
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM