customizing menu items when MENU helper is used

44 views
Skip to first unread message

Vlad

unread,
Jul 30, 2019, 6:09:24 PM7/30/19
to web2py-users
what would be the best way to specify a background color (different for each menu item, depending on some database-driven data) when I build the menu with menu.append(...) in menu.py? 

I would love to have something like this: 

menu.append([description, False, URL('catalog','regimen',args=[id]),[]],_style='background-color:red;')

but of course, this doesn't work this way - 


Dave S

unread,
Jul 31, 2019, 2:48:18 AM7/31/19
to web2py-users

I'd look at using _class instead of _style.  (_class defaults to 'web2py-menu web2py-menu-vertical')

/dps
 

Eliezer (Vlad) Tseytkin

unread,
Jul 31, 2019, 8:13:31 AM7/31/19
to web...@googlegroups.com
It's not really about a menu as a whole (that would be easy). It's about dynamically changing the background color for each menu item individually. In this context I can't pass neither style nor class (in contrast with, for example a list helper where elements/options are made up of another helper and take class, style, and are fully configurable one at a time)... 

--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/AXPsP-HlSLk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/dcaea736-c629-43c7-924a-b07764ce952a%40googlegroups.com.

Dave S

unread,
Jul 31, 2019, 8:00:54 PM7/31/19
to web2py-users


On Wednesday, July 31, 2019 at 5:13:31 AM UTC-7, Vlad wrote:
It's not really about a menu as a whole (that would be easy). It's about dynamically changing the background color for each menu item individually. In this context I can't pass neither style nor class (in contrast with, for example a list helper where elements/options are made up of another helper and take class, style, and are fully configurable one at a time)... 


maybe try set_attribute(), if you have the item?

/dps
 
On Wed, Jul 31, 2019, 2:48 AM Dave S <snide...@gmail.com> wrote:


On Tuesday, July 30, 2019 at 3:09:24 PM UTC-7, Vlad wrote:
what would be the best way to specify a background color (different for each menu item, depending on some database-driven data) when I build the menu with menu.append(...) in menu.py? 

I would love to have something like this: 

menu.append([description, False, URL('catalog','regimen',args=[id]),[]],_style='background-color:red;')

but of course, this doesn't work this way - 



I'd look at using _class instead of _style.  (_class defaults to 'web2py-menu web2py-menu-vertical')

/dps
 

--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/AXPsP-HlSLk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages