SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Keeping Nav Current

    Hey, I am wondering how I might be able to adjust the code below to add an id to the links so that I can display that I am on a certain page in the nav.

    Code:
    <ul id="nav">
    	<li><%= link_to "Blog", :action => "section", :id => 1 %></li>
    	<li><%= link_to "About", :action => "section", :id => 2 %></li>
    	<li><%= link_to "Contact", :action => "section", :id => 3 %></li>
    </ul>
    Maybe similar to link_to_unless_current

    Code:
    <ul id="nav">
    	<li><%= link_to_unless_current "Blog", :action => "section", :id => 1 %></li>
    	<li><%= link_to_unless_current "About", :action => "section", :id => 2 %></li>
    	<li><%= link_to_unless_current "Contact", :action => "section", :id => 3 %></li>
    </ul>
    but the resulting links might look like this if you are in the about section

    Code:
    <ul id="nav">
    <li><a href="section/1">Blog</a></li>
    <li><a href="section/2" id="current">About</a></li>
    <li><a href="section/3">Contact</a></li>
    </ul>
    Thanks in advance. I don't know what i would do without sitepoint forum.

  2. #2
    SitePoint Addict SRTech's Avatar
    Join Date
    Mar 2005
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I saw this, and think it will probably work for you:
    http://mikezornek.com/archives/2005/...t_to_links.php


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •