Sort archive by top and creation date

This commit is contained in:
chris 2013-03-20 17:22:40 +08:00
parent 91afd49f75
commit 031cf927d5
2 changed files with 7 additions and 7 deletions

View File

@ -22,20 +22,20 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
if !params[:category_id].blank? && !params[:tag_id].blank? if !params[:category_id].blank? && !params[:tag_id].blank?
@tag = ArchiveTag.find(params[:tag_id]) rescue nil @tag = ArchiveTag.find(params[:tag_id]) rescue nil
@tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag @tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag
@archive_files = @tag.archive_files.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) @archive_files = @tag.archive_files.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
@archive_files = @archive_files.can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) @archive_files = @archive_files.can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
elsif !params[:category_id].blank? elsif !params[:category_id].blank?
@archive_files = ArchiveFile.can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) @archive_files = ArchiveFile.can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank? elsif !params[:tag_id].blank?
@tag = ArchiveTag.find(params[:tag_id]) rescue nil @tag = ArchiveTag.find(params[:tag_id]) rescue nil
@tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag @tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag
@archive_files = @tag.archive_files.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) @archive_files = @tag.archive_files.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
else else
@archive_files = ArchiveFile.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) @archive_files = ArchiveFile.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
end end
get_categorys get_categorys

View File

@ -28,14 +28,14 @@ class Panel::Archive::Widget::ArchiveFilesController < OrbitWidgetController
date_now = Time.now date_now = Time.now
if !params[:category_id].blank? if !params[:category_id].blank?
@archive_files = ArchiveFile.all.can_display.any_in(:archive_file_category_id => params[:category_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num) @archive_files = ArchiveFile.all.can_display.any_in(:archive_file_category_id => params[:category_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
@archive_file_categorys = ArchiveFileCategory.any_in(:_id => params[:category_id]).excludes('disable' => true) @archive_file_categorys = ArchiveFileCategory.any_in(:_id => params[:category_id]).excludes('disable' => true)
elsif !params[:tag_id].blank? elsif !params[:tag_id].blank?
@tag = ArchiveTag.find(params[:tag_id]) rescue nil @tag = ArchiveTag.find(params[:tag_id]) rescue nil
@tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag @tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag
get_categorys get_categorys
else else
@archive_files = ArchiveFile.all.can_display.merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num) @archive_files = ArchiveFile.all.can_display.merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
get_categorys get_categorys
end end