Module: Knitkit::Extensions::Railties::ActionView::Helpers::KnitkitHelper
- Defined in:
- lib/knitkit/extensions/railties/action_view/helpers/knitkit_helper.rb
Instance Method Summary collapse
-
#build_crumbs(options = {}) ⇒ Object
options nothing - uses current page to lookup section and go up tree menu - menu to look for menu title in menu_item - title of menu_item to start breadcrumbs at section_unique_name - sections permalink to start breadcrumbs at.
- #published_content_created_by ⇒ Object
- #render_version_viewing ⇒ Object
- #tool_tip(message, img_src = nil) ⇒ Object
Instance Method Details
#build_crumbs(options = {}) ⇒ Object
options nothing
-
uses current page to lookup section and go up tree
menu
-
menu to look for menu title in
menu_item
-
title of menu_item to start breadcrumbs at
section_unique_name
-
sections permalink to start breadcrumbs at
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/knitkit/extensions/railties/action_view/helpers/knitkit_helper.rb', line 36 def build_crumbs(={}) if [:menu] = WebsiteNav.find_by_name([:menu]) raise "Menu with name #{[:menu]} does not exist" if .nil? = .website_nav_items.find(:first, :conditions => ["title = ?", [:menu_item]]) raise "Menu Item with Title #{[:menu]} does not exist" if .nil? links = .self_and_ancestors.map{|child| {:url => child.path, :title => child.title}} elsif [:section_unique_name] section = WebsiteSection.find_by_internal_identifier([:section_unique_name]) raise "Website Section with that Internal ID does not exist" if section.nil? links = section.self_and_ancestors.map{|child| {:url => child.path, :title => child.title}} else links = @website_section.nil? ? [] : @website_section.self_and_ancestors.collect{|child| {:url => child.path, :title => child.title}} end render :partial => 'shared/knitkit/bread_crumb', :locals => {:links => links} end |
#published_content_created_by ⇒ Object
8 9 10 |
# File 'lib/knitkit/extensions/railties/action_view/helpers/knitkit_helper.rb', line 8 def published_content_created_by "by #{@published_content.content.created_by.username}" rescue '' end |
#render_version_viewing ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/knitkit/extensions/railties/action_view/helpers/knitkit_helper.rb', line 12 def render_version_viewing html = '' if !session[:website_version].blank? && !session[:website_version].empty? site_version_hash = session[:website_version].find{|item| item[:website_id] == @website.id} unless site_version_hash.nil? if site_version_hash[:version].to_f != @website.active_publication.version html = "<div style='float:left;'>Viewing version #{site_version_hash[:version].to_f} <a href='/view_current_publication'>View current publication</a></div>" end end end raw html end |
#tool_tip(message, img_src = nil) ⇒ Object
55 56 57 58 |
# File 'lib/knitkit/extensions/railties/action_view/helpers/knitkit_helper.rb', line 55 def tool_tip(, img_src=nil) img_src = img_src || '/images/knitkit/tooltip.gif' raw "<a href='#' class='tooltip'> <img src='#{img_src}' alt='ToolTip' /><span>#{}</span></a>" end |