Method: Cms::PageHelper#render_breadcrumbs

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

#render_breadcrumbs(options = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/helpers/cms/page_helper.rb', line 43

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