Manages menu’s in a class based system.
Usage:
>>> menu = web2py_utils.menu.MenuManager(request)
>>> menu.add_menu_item('main_nav', 'Home',
URL(r=request, c='default', f='index'),
activewhen=dict(
a='welcome',
c='default',
f='index',
))
>>> menu.add_menu_item('main_nav', 'Blog',
URL(r=request, c='blog', f='view'),
activewhen=dict(
c='blog',
))
You can render the menu in a OL or UL. If the menu item is active it will assign class=’active’ on the LI element.:
# Assume request
# a = 'welcome'
# c = 'blog'
# f = 'archives'
>>> menu.render_menu('main_nav', type='ol')
<ol class='menu'>
<li><a href="/welcome/default/index"></li>
<li class="active"><a href="/welcome/blog/view"></li>
</ol>
Enter search terms or a module, class or function name.