Module: Cms::PageHelper

Included in:
ApplicationController
Defined in:
app/helpers/cms/page_helper.rb

Instance Method Summary collapse

Instance Method Details

#cms_toolbarObject



26
27
28
# File 'app/helpers/cms/page_helper.rb', line 26

def cms_toolbar
  instance_variable_get("@content_for_layout")
end

#container(name) ⇒ Object



7
8
9
10
11
12
13
14
# File 'app/helpers/cms/page_helper.rb', line 7

def container(name)
  content = instance_variable_get("@content_for_#{name}")
  if logged_in? && @mode == "edit"
    render :partial => 'cms/pages/edit_container', :locals => {:name => name, :content => content}
  else
    content
  end
end

#container_has_block?(name, &block) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
# File 'app/helpers/cms/page_helper.rb', line 16

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_pageObject



3
4
5
# File 'app/helpers/cms/page_helper.rb', line 3

def current_page
  @page
end

#render_breadcrumbs(options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/helpers/cms/page_helper.rb', line 30

def render_breadcrumbs(options={})
  start = options[:from_top] || 0
  show_parent = options[:show_parent].nil? ? false : options[:show_parent]
  ancestors = current_page.ancestors
  items = []
  ancestors[start..ancestors.size].each_with_index do |sec,i|
    items << (: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] = (:li, h(current_page.section.name))
  else
    items << (:li, h(current_page.page_title))
  end
  (:ul, "\n  #{items.join("\n  ")}\n", :class => "breadcrumbs")
end

#render_portlet(name) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'app/helpers/cms/page_helper.rb', line 48

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