Created
June 21, 2011 05:55
-
-
Save priceflex/1037315 to your computer and use it in GitHub Desktop.
EZ Clean Dynamic rails navigation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
# Simple Navigation | |
# navigation nav_elements, :selected_class => "foo" | |
def navigation(links=[],options={}) | |
path = (options[:controller_only] == true) ? controller.controller_name.to_sym : request.path | |
content_tag :ul, :class => (options[:class] || 'navigation') do | |
links.each do |link| | |
klass = (path == link[:path]) ? options[:selected_class] || 'current' : "" | |
klass = "#{link[:class]} #{klass}" | |
concat content_tag(:li, link_to(link[:text], link[:path]), :class => klass) | |
end | |
end | |
end | |
def nav_elements | |
[ | |
{:path => "", :text => "", :class => "first"}, | |
{:path => root_path, :text => "HOME"}, | |
{:path => before_and_after_path, :text => "About Us", :class => 'bar'}, | |
{:path => "", :text => "", :class => "last"} | |
] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment