Module: Goldencobra::NavigationHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/goldencobra/navigation_helper.rb
Instance Method Summary collapse
- #breadcrumb(options = {}) ⇒ Object
-
#navigation_menu(menue_id, options = {}) ⇒ Object
TODO: offset implementieren.
Instance Method Details
#breadcrumb(options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/goldencobra/navigation_helper.rb', line 4 def (={}) id_name = [:id] || "breadcrumb" class_name = [:class] || "" if @article list = "" @article.path.each do |art| link_name = link_to(art., art.public_url) list << content_tag(:li, raw(link_name)) end content_list = content_tag(:ol, raw(list)) if id_name.present? result = content_tag(:nav, raw(content_list), :id => "#{id_name}", :class => "#{class_name}") else result = content_tag(:nav, raw(content_list), :class => "#{class_name}") end return raw(result) end end |
#navigation_menu(menue_id, options = {}) ⇒ Object
TODO: offset implementieren
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/helpers/goldencobra/navigation_helper.rb', line 31 def (, ={}) return "id can't be blank" if .blank? depth = [:depth] || 9999 offset = [:offset] || 0 class_name = [:class] || "" id_name = [:id] || "" = [:submenue_of_article] || "" current_article = [:current_article] || "" if .class == String if current_article.present? && current_article.public_url.present? = Goldencobra::Menue.active.where(:target => current_article.public_url(false)).select{|a| a.path.map(&:title).join("/").include?()}.first if = Goldencobra::Menue.find_by_id(.path_ids[offset]) else return "" end elsif .present? && .public_url.present? = Goldencobra::Menue.active.where(:target => .public_url).select{|a| a.path.map(&:title).join("/").include?()}.first else = Goldencobra::Menue.active.find_by_pathname() end else = Goldencobra::Menue.active.find_by_id() end return "" if .blank? current_depth = .ancestry_depth #Check for Permission if params[:frontend_tags] && params[:frontend_tags].class != String && params[:frontend_tags][:format] && params[:frontend_tags][:format] == "email" #Wenn format email, dann gibt es keinen realen webseit besucher ability = Ability.new() else operator = current_user || current_visitor ability = Ability.new(operator) end if !ability.can?(:read, ) return "" end if .present? content = "" = .subtree.after_depth(current_depth + offset).to_depth(current_depth + depth).active.includes(:permissions).includes(:image) = .to_a.delete_if{|a| !ability.can?(:read, a)} current_depth = 1 ().each do |root| content << (root, , , current_depth) end if id_name.present? result = content_tag(:ul, raw(content),:id => "#{id_name}", :class => "#{class_name} #{depth} navigation #{.css_class.to_s.gsub(/\W/,' ')}".squeeze(' ').strip) else result = content_tag(:ul, raw(content), :class => "#{class_name} #{depth} navigation #{.css_class.to_s.gsub(/\W/,' ')}".squeeze(' ').strip) end end return raw(result) end |