Module: Cms::PagesHelper

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

Instance Method Summary collapse

Instance Method Details

#layouts_for_page(page) ⇒ Object



2
3
4
# File 'app/helpers/cms/pages_helper.rb', line 2

def layouts_for_page(page)
  page.new_record? ? @context.pages.layouts : @context.pages.layouts.reject{|pg| pg == page}
end

#page_match_order(pages, term) ⇒ Object

find the # of term matches in each page and sorts the pages by the match count (highest to lowest) only shows the first SEARCH_LIMIT pages



8
9
10
# File 'app/helpers/cms/pages_helper.rb', line 8

def page_match_order(pages, term)
  pages.collect{|page| [page, page.content.scan(/#{term}/i).length]}.sort{|a,b| b[1] <=> a[1]}[0..(Cms::PagesController::SEARCH_LIMIT-1)]
end