5-minute navigation in Expression Engine
It's nice to highlight the active section in the navigation, but it's not immediately apparent how to do this in EE without duplicating the navigation code on every page.
To maintain some semblance of sanity, I try to keep recurring parts of the site in embedded templates so that if I ever want to change something, I have to do it in 1 place only.
The XHTML
<div id="navigation">
<ul>
<li><a href="#">Home</a></li>
<li class="active"><a href="#">Notebook</a></li>
<li><a href="#">Showcase</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
What section are we on?
Using the {segment_x} template variable, of course:
For example:
...
{if segment_1 == "about"}<li class="active">{if:else}<li>{/if}<a href="#">About</a></li>
...
{segment_1} is the first segment after the index.php in the url:
http://www.nikhedonia.com/{segment_1}/{segment_2}/
What about the homepage?
The homepage is a special case because obviously its url (usually) doesn't include a 1st segment, so we basically check for an empty {segment_1}:
{if segment_1 == ""}<li class="active">{if:else}<li>{/if}<a href="#">Home</a></li>