On 9/20/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I often have CSS designs that call for a tab, link, button, etc; to be > highlighted in some way (usually by having a different class attribute) > from the other links when the user is on the page the navigation > element links to. > > This is a PITA to build. Anyone have some good suggestions? I'm even > thinking about using Javascript instead of doig it server side.
You could pass the current URL (request.path) to the template context, and use the "{% ifequal %}" template tag to compare it. For example: {% ifequal current_url "/about/" %} class="selected"{% endifequal %} Alternatively, you could generate the navigation elements in the view, as a Python data structure, and pass a list of nav elements to the template. {% for nav_element in nav_elements %} <li><a href="{{ nav_element.link }}"{% if nav_element.is_current %} class="selected"{% endif %}</a></li> {% endfor %} Adrian -- Adrian Holovaty holovaty.com | djangoproject.com | chicagocrime.org