diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 123922a1..2aeb9a5a 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -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