Giving the current page nav item a class using embeds
Posted: 18 April 2007 02:02 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  318
Joined  03-07-2006

Hi I’m pretty sure this has been covered I just can’t seem to find it in the forum. How can you use embed conditionals to give the current page list item a class of current?

i.e.

<ul id="nav">
{exp:weblog:entries weblog="home" limit="1"}
    
<li class="current"><a href="#">{title}</a></li>
{/exp:weblog:entries}
</ul>

or even in a static list… I was just going to use if statements like shown I just wondered if there was a better way.

<ul id="nav">
    <
li {if segment_1 == "home"}class="current"{/if}><a href="#">Brief Us Now</a></li>
    <
li {if segment_1 == "advertise"}class="current"{/if}><a href="advertise.htm">I'd Like to <span>Advertise</span></a></li>
    <li {if segment_1 == "alreadyadvertising"}class="current"{/if}><a href="#">I'
m Already <span>Advertising</span></a></li>
    <
li {if segment_1 == "interested"}class="current"{/if}><a href="#">I'm Interested in <span>Radio Ads</span></a></li>
    <li {if segment_1 == "showreels"}class="current"{/if}><a href="#">Showreels</a></li>
    <li {if segment_1 == "team"}class="current last"{/if} class="last"><a href="#">Team Members</a></li>
</ul>

Thanks

 Signature 

· Confused… but happy ·

Profile
 
 
Posted: 18 April 2007 04:44 AM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1455
Joined  09-16-2004

Have a look at this article by the intrepid Derek Jones smile
I’m using this on a site I’m working on right now and it works flawlessly.

 Signature 

Peace, e-man.
stookstudio.com, websites built with care and web standards. LinkedIn profile

Profile
 
 
Posted: 18 April 2007 07:01 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  318
Joined  03-07-2006

Fantastic thanks!

 Signature 

· Confused… but happy ·

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64938 Total Logged-in Users: 55
Total Topics: 81909 Total Anonymous Users: 46
Total Replies: 440308 Total Guests: 296
Total Posts: 522217    
Members ( View Memberlist )