for example 3 is in active state. right now all i can think of is in
each action, just set a variable like @active = ''active'' or
'''', but not
sure what to do with the span.
<ul>
<!-- The link you call "active" will show up as a darker tab
-->
<li><a href="index.html">1</a></li>
<li><a href="index.html">2</a></li>
<li class="active"> <span>3</span> </li>
<li><a href="index.html">4</a></li>
<li><a href="index.html">5</a></li>
</ul>
--
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 Jun 1, 2007, at 10:55 AM, mixplate wrote:> for example 3 is in active state. right now all i can think of is in > each action, just set a variable like @active = ''active'' or '''', but > not > sure what to do with the span. > > <ul> > <!-- The link you call "active" will show up as a darker tab --> > <li><a href="index.html">1</a></li> > <li><a href="index.html">2</a></li> > <li class="active"> <span>3</span> </li> > <li><a href="index.html">4</a></li> > <li><a href="index.html">5</a></li> > </ul> > > --Assuming that the "index.html" would actually be based on the 1, 2, etc.: <ul> <% for example in @examples %> <li><%= link_to_unless_current example, example_path(example) do |text| content_tag(:span, text, :class => ''active'') end %></li> <% end %> </ul> When @examples = [1,2,3,4,5] and example_path(3) => "/example/3" Gives: <ul> <li><a href="/example/1">1</li> <li><a href="/example/2">2</li> <li><span class=''active''>3</span></li> <li><a href="/example/4">4</li> <li><a href="/example/5">5</li> </ul> Is that what you''re looking for? The link_to_if, link_to_unless, link_to_unless_current helpers take a block that is passed the text of the link when the condition isn''t satisfied for making the link. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
(resending without being signed, sorry if the original shows up) On Jun 1, 2007, at 10:55 AM, mixplate wrote:> for example 3 is in active state. right now all i can think of is in > each action, just set a variable like @active = ''active'' or '''', but > not > sure what to do with the span. > > <ul> > <!-- The link you call "active" will show up as a darker tab --> > <li><a href="index.html">1</a></li> > <li><a href="index.html">2</a></li> > <li class="active"> <span>3</span> </li> > <li><a href="index.html">4</a></li> > <li><a href="index.html">5</a></li> > </ul> > > --Assuming that the "index.html" would actually be based on the 1, 2, etc.: <ul> <% for example in @examples %> <li><%= link_to_unless_current example, example_path(example) do |text| content_tag(:span, text, :class => ''active'') end %></li> <% end %> </ul> When @examples = [1,2,3,4,5] and example_path(3) => "/example/3" Gives: <ul> <li><a href="/example/1">1</li> <li><a href="/example/2">2</li> <li><span class=''active''>3</span></li> <li><a href="/example/4">4</li> <li><a href="/example/5">5</li> </ul> Is that what you''re looking for? The link_to_if, link_to_unless, link_to_unless_current helpers take a block that is passed the text of the link when the condition isn''t satisfied for making the link. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I Rob,Thank you for your reply. Actually, the code i pasted would be
more like this:
<ul>
<!-- The link you call "active" will show up as a darker tab
-->
<li> <% link_to :action => get_category, :category =>
''pork'' %>
</li>
<li class="active"> <span>3</span>
</li>
<li><% link_to :action => get_category, :category =>
''beef''
%></li>
</ul>
so @examples would be an array of my category names?
Rob Biedenharn wrote:> (resending without being signed, sorry if the original shows up)
> On Jun 1, 2007, at 10:55 AM, mixplate wrote:
>> <li><a
href="index.html">4</a></li>
>> <li><a
href="index.html">5</a></li>
>> </ul>
>>
>> --
>
> Assuming that the "index.html" would actually be based on the 1,
2,
> etc.:
>
> <ul>
> <% for example in @examples %>
> <li><%= link_to_unless_current example, example_path(example) do
|text|
> content_tag(:span, text, :class =>
''active'')
> end %></li>
> <% end %>
> </ul>
>
> When @examples = [1,2,3,4,5]
> and example_path(3) => "/example/3"
>
> Gives:
> <ul>
> <li><a href="/example/1">1</li>
> <li><a href="/example/2">2</li>
> <li><span
class=''active''>3</span></li>
> <li><a href="/example/4">4</li>
> <li><a href="/example/5">5</li>
> </ul>
>
> Is that what you''re looking for? The link_to_if, link_to_unless,
> link_to_unless_current helpers take a block that is passed the text
> of the link when the condition isn''t satisfied for making the
link.
>
> -Rob
>
> Rob Biedenharn http://agileconsultingllc.com
> Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
--
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
-~----------~----~----~----~------~----~------~--~---
Well, if you need to have
<li class="active"><span> ...
rather than
<li><span class="active> ...
Then you might have to restructure a bit (a listitem_link_to() might
work).
If you can live with decorating the contents of the span rather than
the li, you can do this:
<li><%= link_to_unless_current(example,
:action => ''get_category'',
:category => example) do |text|
content_tag(:span, text, :class => ''active'')
end %></li>
and if the current page''s URL path matches what the parameters
construct, the link will be rendered.
You might also do: (nevermind, the alternative gets too ugly to even
consider. Use a custom helper method if you want to keep your view
cleaner)
Look at the documentation for current_page? and the various link_to
helpers and you ought to be able to figure it out. If you need more
help, show us your actual view and controller code snippets.
-Rob
On Jun 1, 2007, at 1:31 PM, mixplate wrote:> I Rob,Thank you for your reply. Actually, the code i pasted would be
> more like this:
>
> <ul>
> <!-- The link you call "active" will show up as a darker
tab -->
> <li> <% link_to :action => get_category, :category =>
''pork'' %>
> </li>
> <li class="active"> <span>3</span>
</li>
> <li><% link_to :action => get_category, :category =>
''beef''
> %></li>
>
> </ul>
>
>
> so @examples would be an array of my category names?
>
>
> Rob Biedenharn wrote:
>> (resending without being signed, sorry if the original shows up)
>> On Jun 1, 2007, at 10:55 AM, mixplate wrote:
>>> <li><a
href="index.html">4</a></li>
>>> <li><a
href="index.html">5</a></li>
>>> </ul>
>>>
>>> --
>>
>> Assuming that the "index.html" would actually be based on the
1, 2,
>> etc.:
>>
>> <ul>
>> <% for example in @examples %>
>> <li><%= link_to_unless_current example, example_path(example)
do |
>> text|
>> content_tag(:span, text, :class =>
''active'')
>> end %></li>
>> <% end %>
>> </ul>
>>
>> When @examples = [1,2,3,4,5]
>> and example_path(3) => "/example/3"
>>
>> Gives:
>> <ul>
>> <li><a href="/example/1">1</li>
>> <li><a href="/example/2">2</li>
>> <li><span
class=''active''>3</span></li>
>> <li><a href="/example/4">4</li>
>> <li><a href="/example/5">5</li>
>> </ul>
>>
>> Is that what you''re looking for? The link_to_if,
link_to_unless,
>> link_to_unless_current helpers take a block that is passed the text
>> of the link when the condition isn''t satisfied for making the
link.
>>
>> -Rob
>>
>> Rob Biedenharn http://agileconsultingllc.com
>> Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
>
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
Rob Biedenharn http://agileconsultingllc.com
Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
+1 513-295-4739
Skype: rob.biedenharn
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---