Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - name: offersearch
- elements: [header, resulttable]
- autogenerate: [header, resulttable]
- controller: offers
- action: index
- cache: false
- OffersController < Alchemy::BaseController
- def index
- end
- end
- @offers = Offer.where(...)
- # config/alchemy/page_layouts.yml
- - name: searchresults
- elements: [offer_searchresults]
- unique: true
- cache: false
- # app/controllers/alchemy/pages_controller_ext.rb
- module Alchemy
- PagesController.class_eval do
- before_filter :set_searchresult_page, :only => :show
- before_filter :perform_search, :only => :show
- def perform_search
- if params[:searchprofgroup].present? && @search_result_page
- @offers = Offer.where(fb: params[:searchprofgroup])
- end
- end
- private
- def set_searchresult_page
- @search_result_page = Page.published.where(page_layout: "searchresults").first
- end
- end
- end
- # config/application.rb
- config.to_prepare do
- Dir.glob(Rails.root.join("app/**/*_ext*.rb")) do |c|
- Rails.configuration.cache_classes ? require(c) : load(c)
- end
- end
- get '/searchresult' => 'offers#handlesearch', :as => :searchresult
- class OffersController < Alchemy::PagesController
- helper Alchemy::PagesHelper
- def handlesearch
- params[:urlname] = request.path_info.gsub('/', '')
- @page ||= load_page
- if !@page.blank?
- @offers = Offer.where(fb: params[:searchprofgroup])
- else
- render_404
- end
- end
- end
- #/app/views/offers/handlesearch.html.erb
- <%= render_page_layout %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement