簡體   English   中英

我如何檢查某個項目是否屬於特定菜單[Joomla 3.3]

[英]How can i check if an item is part of a specific menu [Joomla 3.3]

我已經知道如何從當前/活動菜單項中解析ID /名稱和內容,但是我想知道它是否屬於特定菜單,例如:

我的菜單名稱為“ mainmenu”,然后鍵入“ mainmenu”: 關於| 聯系| 測試

如果我單擊“關於”,我想知道“關於”是否是“ mainmenu”的一部分-我該怎么做?

像這樣:

$app = JFactory::getApplication();
$menu = $app->getMenu();
$activeitem = $menu->getActive()->id;
// And now the if-statement - which asks if activeitem is part of "mainmenu" and if yes do that, and if not do that...

我希望你知道我的意思...

謝謝你的幫助

您可以使用以下代碼檢查菜單類型-

$app = JFactory::getApplication();
$menu = $app->getMenu();
$menutype = $menu->getActive()->menutype;
if($menutype =='mainmenu'){//check if active menu part of 'mainmenu'

}

暫無
暫無

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

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