我想在布局中创建一个下拉菜单。菜单数据从menu.py
中读取这是我的菜单列表
response.menu_logged = [
(T('Schedules'),URL('default','index')==URL(),URL('default','index')),
(T('New schedule'),URL('script','edit')==URL(),URL('script','edit', args='new')),
(T('Workers'),URL('settings','workers')==URL(),URL('settings','workers')),
(T('Shifts'),URL('settings','turnusi')==URL(),URL('settings','turnusi')),
(T('Config'),URL('settings','config')==URL(),URL('settings','config')),
]
现在我想将工作人员,班次和配置放在一个名为settings
的子菜单(下拉菜单)中和我的layout.html
{{if auth.is_logged_in():}}
<li{{ if response.menu_logged[0][1]: response.write(XML(' class="active"')) }}><a href="{{ =response.menu_logged[0][2] }}">{{ =response.menu_logged[0][0] }}</a></li>
<li{{ if response.menu_logged[1][1]: response.write(XML(' class="active"')) }}><a href="{{ =response.menu_logged[1][2] }}">{{ =response.menu_logged[1][0] }}</a></li>
<li{{ if response.menu_logged[2][1]: response.write(XML(' class="active"')) }}><a href="{{ =response.menu_logged[2][2] }}">{{ =response.menu_logged[2][0] }}</a></li>
<li><a href="https://sites.google.com/site/navodilawoshi/" target="_blank">{{=T('Help')}}</a></li>
有什么建议吗?
我可以用web2py而不是html / css / js吗?
谢谢
答案 0 :(得分:0)
如何使用&#34;嵌套菜单&#34;应用程序中的功能/ welcome / models / menu.py?
你会得到类似的东西:
response.menu_logged = [
(T('Schedules'),URL('default','index')==URL(),URL('default','index')),
(T('New schedule'),URL('script','edit')==URL(),URL('script','edit', args='new')),
(T('Settings'), False, None, [
(T('Workers'),URL('settings','workers')==URL(),URL('settings','workers')),
(T('Shifts'),URL('settings','turnusi')==URL(),URL('settings','turnusi')),
(T('Config'),URL('settings','config')==URL(),URL('settings','config'))])
]
您还可以根据用户登录状态设置2个菜单:
if auth.is_logged_in():
response.menu = [... full menu ...]
else:
response.menu = [... short one ...]