Sha256: 108dae84803282fe34a38a45bf862b9b1994bdf7677be7a5ef670a06e00bb53c
Contents?: true
Size: 488 Bytes
Versions: 5
Compression:
Stored size: 488 Bytes
Contents
module Cms::PagesHelper def layouts_for_page(page) page.new_record? ? @context.pages.layouts : @context.pages.layouts.reject{|pg| pg == page} end # 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 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 end
Version data entries
5 entries across 5 versions & 1 rubygems