I''m incorporating a small navigation bar, and I''d like to highlight the current page''s navigation button. Is there any way to do this? I tried <%= "class=''current''" if current_page?(page) %> -- but that will not work. Any ideas? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Oct 21, 2007, at 11:21 PM, Bob Sanders wrote:> I''m incorporating a small navigation bar, and I''d like to highlight > the > current page''s navigation button. > > Is there any way to do this? > > I tried <%= "class=''current''" if current_page?(page) %> -- but that > will > not work.Assuming you''re running straight /controller/action type URLs, I was recently told you can get that info by using controller.action_name -- gw --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 22 Oct, 07:21, Bob Sanders <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''m incorporating a small navigation bar, and I''d like to highlight the > current page''s navigation button. > > Is there any way to do this?I usually do this through descendant CSS selectors. For example, for each page, I will give a unique ID to the body tag (generally based on the controller name) and each navigation element has a unique ID. ---- application.rhtml ---- <body id="<%= @controller.controller_name %>_body"> <ul> <li><a href="index" id="index_nav">Index</a></li> <li><a href="notes" id="notes_nav">Notes</a></li> </ul> Assuming my controllers share the same name as the href, I would use CSS as follows to highlight the current navigation: #index #index_nav, #notes #notes_nav { font-weight: bold; color: red } Best Regards Robin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > #index #index_nav, > #notes #notes_nav { > font-weight: bold; > color: red > > }Should be: #index_body #index_nav, #notes_body #notes_nav Robin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Oct 21, 11:21 pm, Bob Sanders <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''m incorporating a small navigation bar, and I''d like to highlight the > current page''s navigation button. > > Is there any way to do this? > > I tried <%= "class=''current''" if current_page?(page) %> -- but that will > not work. > > Any ideas? > -- > Posted viahttp://www.ruby-forum.com/.some things to look at: http://snippets.dzone.com/posts/show/2016 http://snippets.dzone.com/posts/show/687 http://rubysnips.com/body-id-s --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
http://railslodge.com/plugins/110-tabnav may be worth a look Bob Sanders wrote:> I''m incorporating a small navigation bar, and I''d like to highlight the > current page''s navigation button. > > Is there any way to do this? > > I tried <%= "class=''current''" if current_page?(page) %> -- but that will > not work. > > Any ideas?-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks all! Wonderful resources and ideas. I can''t thank all of you enough. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Another option is to user link_to_unless_current helper instead of link_to that will deactivate your link on the current page. Hope that helps.. On Oct 22, 7:21 am, Bob Sanders <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''m incorporating a small navigation bar, and I''d like to highlight the > current page''s navigation button. > > Is there any way to do this? > > I tried <%= "class=''current''" if current_page?(page) %> -- but that will > not work. > > Any ideas? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi again guys. Thanks again for the great ideas. This simple one-liner also worked for me too: <%= "class=''current''" if @controller.request.request_uri == (**page_url_here**) %> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---