Set default widget sort to created_at

Don't use page category when home
This commit is contained in:
chris 2013-02-07 17:57:36 +08:00
parent ec9c68f039
commit 3e79b787bb
2 changed files with 6 additions and 6 deletions

View File

@ -16,16 +16,16 @@ class DefaultWidgetController< OrbitWidgetController
if !params["tag_id"].blank?
@tag = Tag.find(params["tag_id"]) rescue nil
if params["category_id"].blank?
result = @tag.send(ori_class_name.downcase.pluralize)
result = @tag.send(ori_class_name.downcase.pluralize).desc(:created_at)
else
result = @tag.send(ori_class_name.downcase.pluralize).where(get_category_field_name(ori_class_name) => params['category_id'])
result = @tag.send(ori_class_name.downcase.pluralize).where(get_category_field_name(ori_class_name) => params['category_id']).desc(:created_at)
end
elsif params["category_id"].blank?
result = eval(@default_widget["query"])
result = eval(@default_widget["query"]).desc(:created_at)
else
result = eval("#{ori_class_name}.where(get_category_field_name(ori_class_name) => params['category_id'])")
result = eval("#{ori_class_name}.where(get_category_field_name(ori_class_name) => params['category_id'])").desc(:created_at)
end
result.available_for_lang(I18n.locale).can_display
result.available_for_lang(I18n.locale).can_display.desc(:created_at)
end
def default_widget

View File

@ -19,7 +19,7 @@ module ParserFrontEnd
end
def parse_page_content(page)
category = params[:category_id].blank? ? page[:category] : params[:category_id]
category = params[:category_id].blank? ? (page[:category] unless page.root?) : params[:category_id]
tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id]
body = Nokogiri::HTML(page.content)
body.css('orbit_front').each do |front|