generating "selected" list entry for nav

1 view
Skip to first unread message

Barry

unread,
Dec 4, 2009, 6:58:32 AM12/4/09
to tahchee
I have a fairly common use case and am looking for a neat solution...

There's a list for the website navigation, and the current page link
is <li class="selected"> to highlight it in the menu. What's the
tahcheeic way of doing this?

Example - for index.html it should do this:

<li class="selected"><a href="index.html">home</a></li>
<li><a href="contact.html">contact</a></li>
<li><a href="login.html">login</a></li>

and for contact.html it should set the class for that list item...

I can think of various ways of doing it in tahchee, but I'm wondering
if anyone has the neatest way that I've probably not found yet...

thanks!

Barry

Johan Oudinet

unread,
Dec 12, 2009, 3:08:32 PM12/12/09
to tah...@googlegroups.com
I personally use the following way:
- In a template page:
<li
#if $page.name() == "index.html"
class="selected"#end if
><a href="index.html">home</a></li>
<li
#if $page.name() == "contact.html"
class="selected"#end if
><a href="contact.html">contact</a></li>
- Then, index.html and contact.html pages should extend this template.

But I don't know if it is neatest way for doing this...

--
Johan
Reply all
Reply to author
Forward
0 new messages