Jeff Casimir wrote:
> Afternoon all,
>
> I am working on a nav menu using the link_to_unless_current helper. I
> am trying to differentiate between the links and non-links using CSS.
> I found an old thread (Feb 2005, [1]) discussing the same
> functionality, but the answer seems a little hack-ish. It would seem
> ideal to me to be able to specify two ":class =>"
designations, one
> for when the subject is linked, one for when it''s not.
Jeff,
I''ve been looking at this kind of thing this evening too.
Try this (untested) helper:
def link_to_mark_current(name, options = {}, html_options = {},
*parameters_for_method_reference)
html_options[:class] = html_options[:current_class] if
current_page?(options) && !html_options[:current_class].nil?
html_options[:current_class] = nil;
link_to(name, options, html_options, *parameters_for_method_reference)
end
Example usage:
<%= link_to_mark_current(''name'',
{:controller=>''pages'',
:action=>''index''},
{:current_class=''current'',
:class=>''not_current''}) %>
--
R.Livsey
http://livsey.org