fix argument passing problem for more link and tag cloud, incomplete code.

This commit is contained in:
Matthew K. Fu JuYuan 2013-05-29 10:21:21 +08:00 committed by Matt K. Fu
parent 6b8b749b0f
commit 5c94200b77
2 changed files with 12 additions and 5 deletions

View File

@ -32,7 +32,7 @@ class PagesController < ApplicationController
if params[:clicked_field_name] if params[:clicked_field_name]
render_page({"clicked_field_name"=>params["clicked_field_name"]}) unless save_from_no_lang_for_page render_page({"clicked_field_name"=>params["clicked_field_name"]}) unless save_from_no_lang_for_page
else else
render_page unless save_from_no_lang_for_page render_page(params) unless save_from_no_lang_for_page
end end
when 'Link' when 'Link'
redirect_to(@item[:url]) unless save_from_no_lang_for_page redirect_to(@item[:url]) unless save_from_no_lang_for_page

View File

@ -19,8 +19,12 @@ module ParserFrontEnd
end end
def parse_page_content(page,args=nil) def parse_page_content(page,args=nil)
tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id] try{
category = params[:category_id].blank? ? page[:category] : params[:category_id] args["category_id"] = args["category_id"].gsub(/\"|\[|\]/,'').split(",").each(&:strip!) if args["category_id"].is_a? String
args["tag_id"] = args["tag_id"].gsub(/\"|\[|\]/,'').split(",").each(&:strip!) if args["category_id"].is_a? String
}
# tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id]
# category = params[:category_id].blank? ? page[:category] : params[:category_id]
body = Nokogiri::HTML(page.content) body = Nokogiri::HTML(page.content)
body.css('orbit_front').each do |front| body.css('orbit_front').each do |front|
if front['value'] if front['value']
@ -29,9 +33,12 @@ module ParserFrontEnd
ret = '' ret = ''
part = PagePart.find(front['part_id']) if front['part_id'] part = PagePart.find(front['part_id']) if front['part_id']
ret << eval("\"#{front['path']}\"") rescue '' ret << eval("\"#{front['path']}\"") rescue ''
args.each do |index,arg| args.each do |index,arg|
if index=="tag_id" || index=="category_id"
ret << (ret.include?("?") ? "&#{index}[]=#{arg}": "?#{index}[]=#{arg}" )
else
ret << (ret.include?("?") ? "&#{index}=#{arg}": "?#{index}=#{arg}" ) ret << (ret.include?("?") ? "&#{index}=#{arg}": "?#{index}=#{arg}" )
end
end if args end if args
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div class='dymanic_load widget' path='#{ret}'></div>") fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div class='dymanic_load widget' path='#{ret}'></div>")
end end