[web2py] Re: Add conditional sub-menu

2018-02-08 Thread 'jim kaubisch' via web2py-users
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

[web2py] Re: Add conditional sub-menu

2013-09-04 Thread 黄祥
i found the same difficulty during add conditional sub menu, in my case the conditional is base on session. i've followed cliff hints above using sub_menu = [], it work well as long as the condition is meet (there is a session), but the problem occured when i clear the session. is there any sol

[web2py] Re: Add conditional sub-menu

2012-04-27 Thread Cliff
Sorry I didn't see this sooner. I think all your menu items will want that empty list, and I see some do not. Also I am confused about how a menu script could cause a dal to raise an exception. Maybe somebody with a better knowledge of the internals will chime in here. On Wednesday, April 25

[web2py] Re: Add conditional sub-menu

2012-04-25 Thread Omi Chiba
Thanks again ! I came back from vacation and tried the code but I got different error... File "C:\web2py\gluon\dal.py", line 1386, in log_execute ret = self.cursor.execute(*a, **b) ProgrammingError: The cursor's connection has been closed. sub_menu = [('Admin', False, URL('admin'), []),

Re: [web2py] Re: Add conditional sub-menu

2012-04-15 Thread Omi Chiba
Cliff, Thanks ! I'm on vacation but I will try when I come back but I'm sure it works !! On Sun, Apr 15, 2012 at 9:52 PM, Cliff wrote: > Omi, > > Sorry, my bad. Been away. > > Should be: > sub_menu = [('Admin', False, URL('admin'), []), ] # Added empty list > > On Thursday, April 12, 20

[web2py] Re: Add conditional sub-menu

2012-04-15 Thread Cliff
Omi, Sorry, my bad. Been away. Should be: sub_menu = [('Admin', False, URL('admin'), []), ] # Added empty list On Thursday, April 12, 2012 9:43:39 AM UTC-4, Omi Chiba wrote: > > Cliff, > > Thank you for sharing code but now I got a different error. Maybe it > cannot understand sub_menu

Re: [web2py] Re: Add conditional sub-menu

2012-04-12 Thread Omi Chiba
Nice approach. I will try for my another project ! On Thursday, April 12, 2012 5:18:58 AM UTC-5, Javier wrote: > > I was working on a set menu from the database. It's simple and it can be > useful. > The model is simple, and has a condition to evaluate options when > generating the menu items. >

[web2py] Re: Add conditional sub-menu

2012-04-12 Thread Omi Chiba
Cliff, Thank you for sharing code but now I got a different error. Maybe it cannot understand sub_menu contains three parameters.. Traceback (most recent call last): File "C:\web2py\gluon\restricted.py", line 205, in restricted exec ccode in environment File "C:\web2py\applications\home

Re: [web2py] Re: Add conditional sub-menu

2012-04-12 Thread Javier Pepe
I was working on a set menu from the database. It's simple and it can be useful. The model is simple, and has a condition to evaluate options when generating the menu items. The evaluation was done using the function 'eval'. Attach model. To manage SQLFORM.grid use or what you like db.define_table

[web2py] Re: Add conditional sub-menu

2012-04-11 Thread Cliff
I have something like this working: sub_menu = [] if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))): sub_menu = [('Admin', False, URL('admin')), ] response.menu = [('Home', False, URL('home','default','index'), []), (SPAN('Price List',_style='color:yellow'), True, UR