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]
render_page({"clicked_field_name"=>params["clicked_field_name"]}) unless save_from_no_lang_for_page
else
render_page unless save_from_no_lang_for_page
render_page(params) unless save_from_no_lang_for_page
end
when 'Link'
redirect_to(@item[:url]) unless save_from_no_lang_for_page

View File

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