this is an old thread, but I needed to do add a conditional piece to a menu - but had trouble with all the options below.
Then I realized that response.menu is a list, hence rather than if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))): response.menu += [('Admin', False, URL('admin')), ] the following: if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))): response.menu.append( [('Admin', False, URL('admin')), ]) worked for me :-) Mine actually included simple dropdown submenus... if (auth.user_id != None) and (auth.has_membership(role = 'admin')): response.menu.append ([' Admin', False, None, [ ['Show Meta Data' , False, URL('my_admin', 'show_meta_data' , vars=dict(meta_op='meta_show'))], ['Backup Database', False, URL('my_admin', 'backup_database', vars=dict(db_op ='db_backup'))], ['Backup Database', False, URL('my_admin', 'backup_database', vars=dict(db_op ='db_restore'))] ] ]) On Wednesday, April 11, 2012 at 9:24:29 AM UTC-7, Omi Chiba wrote: > > The following menu works. It's add "Admin" menu next to "Price List" if > the user has role "admin". Now, I want to add the "Admin" menu as sub-menu > of "Price List" where it's right after the "Cut Charge Tables". How can I > do this ? > > response.menu = [('Home', False, URL('home','default','index'), []), > (SPAN('Price List',_style='color:yellow'), True, > URL('pricelist','default','index'), > [('Guideline', False, URL('pricelist','default','guideline')), > ('Multiplier Tables', False, > URL('pricelist','default','multitable')), > ('Cut Charge Tables', False, URL('pricelist','default','cuttable')), > ])] > > if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))): > response.menu += [('Admin', False, URL('admin')), ] > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.