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

Reply via email to