missed the "very detailed post".
what does it mean that you want help with menu comprehension using a
controller ?
The menu can be defined wherever you want. Having it defined in models is
just a shortcut to avoid having to redefine it over and over, because
usually the menu is "fixed".
That being said, response.menu is just a list of tuples, optionally
containing another list as the fourth argument.
The scaffolding app has a pretty extensive menu where you can see the
structure needed to generate the menu.
Basically each item is
(text, active_or_not, html_helper, [childrens])
now, let's forget for a second about:
- active_or_not (it just decorates with an "active" class the element)
- html_helper (you can put whatever you want, but then you'd override the
text part)
usually the menu item is
(text, False, URL('bla', 'bla') , [childrens])
This creates an A() tag, that holds "text" as value, URL('bla', 'bla') as
link, and has submenus (one for each item listed in childrens)
to sum up, to have a menu that basically is
- menu 1
- menu 1.1
- menu 1.2
- menu2
you'd have something like
response.menu = [
('menu 1', False, URL('bla', 'bla'), [
('menu 1.1', False, URL('bla', 'bla')),
('menu 1.2', False, URL('bla', 'bla'))
]),
('menu 2', False, URL('bla', 'bla'))
]
>From there on, it's basic list slicing and dicing with python.
let's say you'd like to "insert" a "menu 1.3" in your controller, so in
that particular page only, a menu 1.3 would be visible....
you'd have to append the new element to the fourth element (the [children]
list) of the first menu.
Remembering that python lists are 0-indexed :
response.menu[0][3].append(
('menu 1.3', False, URL('bla', 'bla'))
)
And voilĂ .
Clearer ?
On Wednesday, May 29, 2013 12:04:27 AM UTC+2, greaneym wrote:
>
> I posted a very detailed explanation of my progress so far and what I
> needed further. I can see it in the web2py-group posting but maybe you
> cannot see it? I need further help with menu comprehension using a
> controller instead of a model file. I can post again if you can't see the
> request. thanks.
>
>
> On Tuesday, May 28, 2013 3:25:53 PM UTC-5, Niphlod wrote:
>>
>>
>>
>> On Tuesday, May 28, 2013 10:15:24 PM UTC+2, greaneym wrote:
>>>
>>> Thanks that was helpful and got me further but I need a bit more help.
>>>
>>>
>>>
>> on what ?
>>
>
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.