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

Version Path
liquid_cms-0.3.2.0 app/helpers/cms/pages_helper.rb
liquid_cms-0.2.2.0 app/helpers/cms/pages_helper.rb
liquid_cms-0.2.1.1 app/helpers/cms/pages_helper.rb
liquid_cms-0.3.1.0 app/helpers/cms/pages_helper.rb
liquid_cms-0.2.1.0 app/helpers/cms/pages_helper.rb