Page front end stay in the same page when a link is clicked (category)

This commit is contained in:
chris 2013-03-19 19:44:04 +08:00
parent 37a38369e7
commit 14d856b4d6
1 changed files with 4 additions and 3 deletions

View File

@ -64,9 +64,11 @@ class PagesController < ApplicationController
protected
def get_item
if params[:page_id]
if !params[:page_id].blank?
@item = Item.find(params[:page_id])
elsif params[:same_page_id]
elsif !params[:orig_page].blank?
@item = Item.find(params[:orig_page])
elsif !params[:same_page_id].blank?
@item = Item.find(params[:same_page_id])
else
category_ids = params[:category_id].is_a?(Array) ? params[:category_id] : [params[:category_id]]
@ -80,7 +82,6 @@ class PagesController < ApplicationController
elsif !tag_ids.blank?
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], :tag.in => tag_ids).any_in(category: [nil, []]).first
end
@item = Item.find(params[:orig_page]) unless @item || params[:orig_page].blank?
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action]).all_of("tag" => {"$in" => [nil, []]},"category" => { "$in" => [nil, []]}).first unless @item
@item = Item.where(module_app_id: module_app.id, app_frontend_url: 'default_widget').first unless @item
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action]).first unless @item