Skip to content

Instantly share code, notes, and snippets.

@HusseinMorsy
Created November 25, 2009 10:06
Show Gist options
  • Save HusseinMorsy/242611 to your computer and use it in GitHub Desktop.
Save HusseinMorsy/242611 to your computer and use it in GitHub Desktop.
module AddTopNavigation
module ClassMethods
def add_top_navigation( opts = {} )
before_filter opts do |controller|
controller.send(:add_top_navigation, opts)
end #before_filter
end
end
module InstanceMethods
def add_top_navigation( opts = {} )
# Top Navigation Ebene 2
Genre.all(:order => "position").each do |genre|
add_topnav_level2_item genre.title, genre, :active => :hmmmmm
end
add_topnav_level2_item( 'navigation.top.account', account_url, :active => :hmmmmm ) if admin_authorized?
add_topnav_level2_item( 'navigation.top.login', login_url, :active => :hmmmmm ) unless logged_in?
add_topnav_level2_item( 'navigation.top.logout', logout_url, :active => :hmmmmm ) if logged_in?
add_topnav_level2_item( 'navigation.top.line_item', '/line_items', :active => :hmmmmm )
# Top Navigation Ebene 3
# add_topnav_level3_item :all, "topnav_filters.pos01.title", I18n.t('topnav_filters.pos01.url', :root => root_url), :active => 'NIX'
end
end
def self.included(receiver)
receiver.extend ClassMethods
receiver.send :include, InstanceMethods
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment