Module: Cms::PageHelper
- Included in:
- ApplicationController
- Defined in:
- app/helpers/cms/page_helper.rb
Instance Method Summary collapse
- #cms_toolbar ⇒ Object
- #container(name) ⇒ Object
- #container_has_block?(name, &block) ⇒ Boolean
- #current_page ⇒ Object
- #page_title(*args) ⇒ Object
- #render_breadcrumbs(options = {}) ⇒ Object
- #render_portlet(name) ⇒ Object
Instance Method Details
#cms_toolbar ⇒ Object
34 35 36 |
# File 'app/helpers/cms/page_helper.rb', line 34 def instance_variable_get("@content_for_layout") end |
#container(name) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/helpers/cms/page_helper.rb', line 15 def container(name) content = instance_variable_get("@content_for_#{name}") if logged_in? && @page && @mode == "edit" && current_user.able_to_edit?(@page) render :partial => 'cms/pages/edit_container', :locals => {:name => name, :content => content} else content end end |
#container_has_block?(name, &block) ⇒ Boolean
24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/cms/page_helper.rb', line 24 def container_has_block?(name, &block) has_block = (@mode == "edit") || current_page.connectable_count_for_container(name) > 0 logger.info "mode = #{@mode}, has_block = #{has_block}" if block_given? concat(capture(&block)) if has_block else has_block end end |
#current_page ⇒ Object
11 12 13 |
# File 'app/helpers/cms/page_helper.rb', line 11 def current_page @page end |
#page_title(*args) ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/helpers/cms/page_helper.rb', line 3 def page_title(*args) if args.first @controller.instance_variable_get("@template").instance_variable_set("@page_title", args.first) else @controller.instance_variable_get("@template").instance_variable_get("@page_title") end end |
#render_breadcrumbs(options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/helpers/cms/page_helper.rb', line 38 def (={}) start = [:from_top] || 0 show_parent = [:show_parent].nil? ? false : [:show_parent] ancestors = current_page.ancestors items = [] ancestors[start..ancestors.size].each_with_index do |sec,i| items << content_tag(:li, link_to(h(sec.name), sec.actual_path), (i == 0 ? {:class => "first"} : {})) end if !show_parent && current_page.section.path == current_page.path items[items.size-1] = content_tag(:li, h(current_page.section.name)) else items << content_tag(:li, h(current_page.page_title)) end content_tag(:ul, "\n #{items.join("\n ")}\n", :class => "breadcrumbs") end |
#render_portlet(name) ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/cms/page_helper.rb', line 56 def render_portlet(name) portlets = Portlet.all(:conditions => ["name = ?", name.to_s]) if portlets.size > 1 @mode == "edit" ? "ERROR: Multiple Portlets with name '#{name}'" : nil elsif portlets.empty? @mode == "edit" ? "ERROR: No Portlet with name '#{name}'" : nil else render_connectable(portlets.first) end end |