简体   繁体   English

我如何检查某个项目是否属于特定菜单[Joomla 3.3]

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

i already know how to parse id/name and stuff from my current/active menu-item, but i want to know if it's part of a specific menu for example: 我已经知道如何从当前/活动菜单项中解析ID /名称和内容,但是我想知道它是否属于特定菜单,例如:

I have this Menu with the name "mainmenu" and type "mainmenu": Home | 我的菜单名称为“ mainmenu”,然后键入“ mainmenu”: About | 关于| Contact | 联系| Testing 测试

If i click on About i want to know if About is part of "mainmenu" - how can i do that? 如果我单击“关于”,我想知道“关于”是否是“ mainmenu”的一部分-我该怎么做?

like this: 像这样:

$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...

I hope you know what i mean... 我希望你知道我的意思...

Thanks for any help 谢谢你的帮助

You can check menutype using below code - 您可以使用以下代码检查菜单类型-

$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