You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hello,
I'm making a website with bootstrap and I use some menu items (in
fact nav bars) and I was wondering what is the best practice to make a
menu item highlighted when I am on the page connected with this menu
item. I mean in bootstrap the nav bar has a <li class="active"> to
highlight the fact that I'm on this page. I was wondering if I should
use django context to give the information and set in the template {% if
currentpage="home" %} class="active" {% endif %} or if I should use
some javascript code to look in which page I am and set the
class="active". Sorry if this is not the correct mailing list to send
this question but I don't know where to start looking so any information
is welcome (for exemple if there is standard practice for this kind of
things can someone give me some input?)
sincerely
L
ludovic coues
unread,
Oct 10, 2016, 3:23:51 PM10/10/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Personally, I pass a dict named current in the context. For the home
page, the dict is {'home': 'active'} and for about, it's {'about':
'active'}. Then the link to the home page is <li class="{{
current.home }}">, the link to about is <li class="{{ current.about
}}">, etc...
It might not be the best way but it's pretty straightforward and
that's what I use when I need to highlight the current page.
I'm curious to read about how other django's user are doing it :)