SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Dec 13, 2007, 12:51 #1
- Join Date
- Oct 2007
- Posts
- 49
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Displaying Active Link in CSS generated menu...that is located in the layout
I am using a layout in a Ruby project. Basically it just displays the header with logo, navigation, and then yields for the content. After the content is displayed, the layout takes care of displaying the footer.
What I would like to do...is somehow display which link is active in the CSS menu...which again, is located in the layout.
Is this possible? Would it be better to just move the navigation code into each view? I could get that to work of course...but I would have to change code in all the views should my categories/nav bar change.
I think I worded that in a way that makes sense?
-
Dec 13, 2007, 13:59 #2
- Join Date
- Feb 2006
- Location
- Worcs. UK
- Posts
- 404
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can have dynamic content in your layout as well as within your view. So you can create a navigation bar in the layout and then dynamically control its content.
Have a look at link_to_unless_current:
http://api.rubyonrails.com/classes/A...r.html#M000902
That gives you a way of easily managing links and changing their content if you are view the page the link refers to.
You could also have a look at this posting about creating navigation links:
http://snippets.dzone.com/posts/show/1996
Bookmarks