On Monday, January 9, 2012 11:57:52 AM UTC+5:30, Victor Hooi wrote:
>
> hi,
>
> I have a project where I'm using Bootstrap (
> www.github.com/twitter/bootstrap) with Django.
>
> I need to add a CSS class ("active") to highlight the active navigation 
> link.
>
> Anyhow, I did some Googling:
>
> http://www.turnkeylinux.org/blog/django-navbar
>
> http://ilostmynotes.blogspot.com/2010/03/django-current-active-page-highlighting.html
>
> http://gnuvince.wordpress.com/2007/09/14/a-django-template-tag-for-the-current-active-page/
> http://stackoverflow.com/questions/340888/navigation-in-django
> http://djangosnippets.org/snippets/1726/
>
> http://stackoverflow.com/questions/7665514/django-highlight-navigation-based-on-current-page
>
> The approach in the above seems to be to either use custom template tag, 
> middleware or JS-hackery.
>
> Is there a current consensus in the Django community in terms of what is 
> the "correct" approach for this?
>
> Is there a reason something like this isn't part of Django core, or an 
> in-built templatetag?
>
> Cheers,
> Victor
>



i did this by  adding  {% block activepage %}{% endblock %} in my base 
template and in a page which extended from the basic template i added {% 
block activepage %} class="active" {% endblock %}  where active class does 
the highlight in CSS.

I think JS/jQuery is neat but if you are not comfortable with it i think 
templates do the trick.. :)

 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/9m0Ss0Od_LUJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to