最简单的方法来指示当前的response.menu项目到web2py的菜单助手?

时间:2016-10-20 16:39:18

标签: web2py

据了解,MENU助手可以通过两种方式指示当前菜单项,并为该项web2py-menu-active添加<li>类。对每个菜单项的第二项使用表达式是一种非常手动的千篇一律的方法,涉及大量的剪切和粘贴。

因此,提供active_url参数更具代码效率。

显然the way to get the current URL in web2py has already been answered但我想确认下面的代码是理想的代码,用于告知MENU哪个菜单项要追加web2py-menu-active

MENU(    ...., active_url=URL(args=request.args, vars=request.get_vars, host=True))

1 个答案:

答案 0 :(得分:1)

这有效:

{{=MENU(response.menu, 
    _class='nav navbar-nav', li_class='dropdown', 
    ul_class='dropdown-menu', active_url=request.url)}}