Fix get_item and more link in front end
This commit is contained in:
parent
837dc3ea7b
commit
3c3bba514a
|
@ -98,21 +98,20 @@ class PagesController < ApplicationController
|
|||
elsif params[:same_page_id]
|
||||
@item = Item.find(params[:same_page_id])
|
||||
else
|
||||
category_ids = params[:category_id].is_a?(Array) ? params[:category_id] : [params[:category_id]]
|
||||
tag_ids = params[:tag_id].is_a?(Array) ? params[:tag_id] : [params[:tag_id]]
|
||||
category_ids = params[:category_id].is_a?(Array) ? params[:category_id] : [params[:category_id]] unless params[:category_id].nil?
|
||||
tag_ids = params[:tag_id].is_a?(Array) ? params[:tag_id] : [params[:tag_id]] unless params[:tag_id].nil?
|
||||
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
|
||||
if !category_ids.blank? && !tag_ids.blank?
|
||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category.in => category_ids, :tag.in => tag_ids})
|
||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category.in => category_ids, :tag.in => [nil, []]}) unless @item
|
||||
@item = Item.first(:conditions => {is_published: true, :module_app_id => module_app.id, :app_frontend_url.in => [params[:app_action], 'default_widget'], :category.in => category_ids, :tag.in => tag_ids})
|
||||
@item = Item.first(:conditions => {is_published: true, :module_app_id => module_app.id, :app_frontend_url.in => [params[:app_action], 'default_widget'], :category.in => category_ids, :tag.in => [nil, []]}) unless @item
|
||||
elsif !category_ids.blank?
|
||||
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], :category.in => category_ids).any_in(tag: [nil, []]).first
|
||||
@item = Item.where(is_published: true, module_app_id: module_app.id, :app_frontend_url.in => [params[:app_action], 'default_widget'], :category.in => category_ids).any_in(tag: [nil, []]).first
|
||||
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
|
||||
@item = Item.where(is_published: true, module_app_id: module_app.id, :app_frontend_url.in => [params[:app_action], 'default_widget'], :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
|
||||
@item = Item.where(is_published: true, module_app_id: module_app.id, :app_frontend_url.in => [params[:app_action], 'default_widget']).all_of("tag" => {"$in" => [nil, []]},"category" => { "$in" => [nil, []]}).first unless @item
|
||||
@item = Item.where(is_published: true, module_app_id: module_app.id, :app_frontend_url.in => [params[:app_action], 'default_widget']).first unless @item
|
||||
end
|
||||
raise PageError,'Missing Frontend Page' if @item.nil?
|
||||
end
|
||||
|
|
|
@ -6,15 +6,14 @@ module DefaultWidgetTagHelper
|
|||
@request = req
|
||||
params.delete :inner
|
||||
@params = params
|
||||
|
||||
params_str ="?"
|
||||
params_str = "?"
|
||||
params.each do |index,param|
|
||||
if param.is_a?(Array) and !param.blank?
|
||||
params_str << "&" unless params_str.eql?("?")
|
||||
params_str << param.collect{|t| "#{index}[]=#{t}"}.join("&")
|
||||
params.delete index
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
params_str = params_str + (params_str.eql?("?") ? params.to_param : "&#{params.to_param}" )
|
||||
content_tag :div,:class=> 'more' do
|
||||
link_to I18n.t(@more_link[:label_i18n]),[eval("#{@more_link[:path_method]}"),params_str].join()
|
||||
|
|
Loading…
Reference in New Issue