The <ul>...</ul> code in Django in web2py translates with
{{=MENU(response.menu)}}
where (using the data in your example)
response.menu=[
('Home',request.function=='home',URL(r=request,f='home'),[]),
('Store Information',request.function=='info',URL(r=request,f=info'),
[]),
]
The latter code can go in menu.py but you can place it in any mode.
MENU(...) takes arguments that allows you to customize the class of
the <ul> amd <li>. It also handles submenu (the [] above are
submenus).
On Aug 3, 4:38 pm, mwolfe02 <[email protected]> wrote:
> I wrote this simple website using Django (http://www.heberlings.com/). As
> part of the navigation, I wanted to turn off
> the link for the currently active page. If you visit the site and
> click on a couple of the menu items on the left side of the page, you
> will see what I mean.
>
> To implement this in Django, I did the following in my base.html view
> (or as Django calls it, template):
>
> <!-- Start of left-hand side navigation -->
> {% url heb-home as url_home %}
> {% url heb-info as url_info %}
> ...
> <div id="nav">
> <ul>
> {% ifequal request.path url_home %}
> <li id="current">Home</li>
> {% else %}
> <li><a href="{{ url_home }}">Home</a></li>
> {% endifequal %}
> {% ifequal request.path url_info %}
> <li id="current">Store Information</li>
> {% else %}
> <li><a href="{{ url_info }}">Store Information</a></li>
> {% endifequal %}
> ...
>
> I always felt this was kludgy and I had trouble getting it to work
> just right. (Note: I did this a couple of years ago, things may have
> changed in Django since then.)
>
> My question is this: how would I do this sort of thing in web2py?
> Should I implement this in models/menu.py? What is the best practice?
>
> Thanks in advance,
> Mike