Archive: ComponentOwl Rails app, DB backups, go redirect script
This commit is contained in:
53
app/controllers/faqs_controller.rb
Normal file
53
app/controllers/faqs_controller.rb
Normal file
@@ -0,0 +1,53 @@
|
||||
class FaqsController < ApplicationController
|
||||
|
||||
before_filter :init_objects, :except => [:search]
|
||||
before_filter :init_params, :only => [:search]
|
||||
|
||||
caches_page :index, :show
|
||||
|
||||
def index
|
||||
render :action => "show"
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def search
|
||||
#buga> uz budou mit dalsi produkty faqs, tohle se musi predelat
|
||||
@product = featured_product
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @faqs }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def init_params
|
||||
params[:search] ||= {}
|
||||
params[:search] ||= {}
|
||||
params[:search][:order] ||= "ascend_by_position"
|
||||
|
||||
@search = Faq.search(params[:search])
|
||||
@faqs = @search.all
|
||||
end
|
||||
|
||||
def init_objects
|
||||
if params[:product]
|
||||
@product = Product[params[:product]]
|
||||
@categories = @product.faq_categories.all_ordered
|
||||
else
|
||||
@categories = FaqCategory.common
|
||||
end
|
||||
|
||||
if params[:id]
|
||||
@categories.each {|category| @category = category if category.url_param == params[:id] }
|
||||
else
|
||||
@category = @categories.first
|
||||
end
|
||||
|
||||
@faqs = @category.faqs
|
||||
@products = Product.all_ordered
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user