Module: Ramaze::Helper::Pages

Included in:
CortexReaver::Model::Renderer
Defined in:
lib/cortex_reaver/helper/pages.rb

Instance Method Summary collapse

Instance Method Details

Gives a list of lists showing page heirarchy navigation. Expands to show the current page if given.



6
7
8
9
10
11
12
# File 'lib/cortex_reaver/helper/pages.rb', line 6

def page_navigation(current=nil)
  l = "<ul>\n"
  CortexReaver::Page.top.all.each do |page|
    l << page_navigation_helper(page, current)
  end
  l << '</ul>'
end


23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cortex_reaver/helper/pages.rb', line 23

def page_navigation_helper(page, current=nil)
  l = '<li' + (page == current ? ' class="selected"' : '') + '>'
  l << "<a href=\"#{page.url}\">#{h page.title}</a>"
  if page.pages and current and current.within? page
    l << "\n<ul>"
    page.pages.each do |page| 
      l << page_navigation_helper(page, current)
    end
    l << "</ul>\n"
  end
  l << "</li>\n"
end

#page_select(id, params = {}) ⇒ Object

Returns a page selector



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/cortex_reaver/helper/pages.rb', line 37

def page_select(id, params={})
  type = params[:type]
  p_class = params[:p_class]
  description = params[:description] || id.to_s.titleize
  model = params[:model]
  default_id = params[:default_id]
  skip_id = params[:skip_id]

  f = "<p #{p_class.nil? ? '' : 'class="' + attr_h(p_class) + '"'}>"
  f << "<label for=\"#{id}\">#{description}</label>"
  f << "<select name=\"#{id}\" id=\"#{id}\">"
  f << "<option value="">/</option>"
  CortexReaver::Page.top.order(:title).all.each do |page|
    f << page_select_helper(page, default_id, skip_id)
  end
  f << "</select></p>"
end

#subpage_navigation(page) ⇒ Object

A list of pages belonging to the given page.



15
16
17
18
19
20
21
# File 'lib/cortex_reaver/helper/pages.rb', line 15

def subpage_navigation(page)
  l = "<ul>\n"
  page.pages.each do |page|
    l << page_navigation_helper(page)
  end
  l << "</ul>"
end