Rails 3 - Referencing the URL to determine if a Nav Item is class="selected" -
the app can have following urls:
i'd know how in rails 3 can @ current url , know of lines above active, can add class="selected"
additional exmaple..
if user's browser on: /projects
and nav looks like
projects - photos - files
projects active
but if user's browser on: /files
projects active
and files active (they both apply).
ideas? thanks
there access params hash, can check params[:controller] or params[:action] anywhere in views. there request.env['path_info'], complete url stored well.
as breadcrumb referenced in second part of question, believe there no general way of doing it. there no solid background behind relations between views. site logic constructed across views, there no solid way of determining it.
since have files underneath project in particular view, problem? can't highlight project if files selected?
edit:
implementation depends on design , if need direct hints, have paste gist/paste link code. in general idea follows:
<% if params[:controller] == :files <% b1class = "active" %> <% b2class = "active" %> <% b3class = "active" %> <% else %> .... <% end %> <div class=breadcrumb> <p class=<%= b1class> project </p> <p class=<%= b2class> photos </p> <p class=<%= b3class> files </p> </div>
Comments
Post a Comment