2017-02-28 110 views

回答

0

为了识别您所在的页面,可能更容易在body类中输出itemId参数,因此编辑您的模板主文件(通常为/templates/something/index.php)并找到<body标记,然后像这样更改它:

<body class="your other classes here <?php 
    $app = JFactory::getApplication(); 
    $menu = $app->getMenu()->getActive()->id; 
    echo "pageid-$itemId" 
?>" 

这将呈现为

<body class="your other classes here pageid-1302"> 

然后,假设你的页面要引进此修复程序到具有的itemId 1302,你可以简单地用它来定位导航作为一个自定义的CSS规则要求:

body.pageid-1302 nav.main > ul > li:nth-child(3):hover > ul > li:nth-child(2) { 
    display:none; 
} 

(注意:这只是一个例子,我没有你的课,你必须找到正确的路径只针对子菜单的想法。 另外,请确保您使用手机进行测试,因为有时类别不同。

此解决方案不使用脚本;如果您希望隐藏的子菜单是悬停的项目的子项,它将很容易工作;但是如果项目位于其他地方,则确实需要脚本。在这种情况下,你需要的功能附加到悬停事件,并采取相应的行动:假设jQuery是可用:

jQuery(function() { 
    // now the document is loaded 
    jQuery('.firstmenuselector').on('hover',function() { 
    // the user hovered the element; 
    jQuery('.submenuselector').hide(); 
    },function() { 
    // the user exited the element; 
    jQuery('.submenuselector').show(); 
    }); 
}); 

最后,你可能要添加一个类所涉及的菜单项,所以它将更容易与一个CSS或jQuery选择器的目标。

+0

非常感谢你,我会试试这个解决方案。 –