fix order
This commit is contained in:
parent
b854e25b30
commit
00e62d3363
|
@ -6,24 +6,24 @@ class AnnouncementsController < ApplicationController
|
|||
announcements = nil
|
||||
|
||||
if params[:keywords]
|
||||
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:postdate=>"desc"}
|
||||
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:is_top=>"desc",:postdate=>"desc"}
|
||||
announcements = Bulletin.where(:title.ne => "").any_of(:title => /#{params[:keywords].to_s}/i).is_approved.order_by(sort).filter_by_categories(["all"]).per(15) if !params[:keywords].nil?
|
||||
announcements_count = announcements.count
|
||||
keyword = "搜尋標題有關 ' " + params[:keywords] + " '"
|
||||
|
||||
elsif params[:unit]
|
||||
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:postdate=>"desc"}
|
||||
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:is_top=>"desc",:postdate=>"desc"}
|
||||
announcements = Bulletin.where(:title.ne => "" ,:cache_dept => params[:unit].to_s).is_approved.order_by(sort).filter_by_categories(["all"]).per(15) if !params[:unit].nil?
|
||||
announcements_count = announcements.count
|
||||
keyword = "列出由:" + params[:unit] + "發佈的資料"
|
||||
|
||||
elsif params[:tag]
|
||||
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:postdate=>"desc"}
|
||||
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:is_top=>"desc",:postdate=>"desc"}
|
||||
announcements = Bulletin.where(:title.ne => "" ,:is_preview.in=>[false,nil]).is_approved.order_by(sort).filter_by_categories(["all"]).filter_by_tags([params[:tag]])
|
||||
keyword = "搜尋有關 ' " + Tag.where(:id => params[:tag]).first.name + " '"
|
||||
|
||||
elsif params[:category]
|
||||
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:postdate=>"desc"}
|
||||
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:is_top=>"desc",:postdate=>"desc"}
|
||||
category = Category.find_by(:uid => params["category"].split("-").last) rescue nil
|
||||
announcements = Bulletin.all.where(:title.ne => "").is_approved.order_by(sort).filter_by_categories([category.id.to_s]) if !category.nil?
|
||||
announcements_count = announcements.count
|
||||
|
@ -37,7 +37,7 @@ class AnnouncementsController < ApplicationController
|
|||
end
|
||||
|
||||
else
|
||||
sort = ( !params[:sort].blank? ? {params[:sort].to_sym=>params[:order]} : {:postdate=>"desc"})
|
||||
sort = ( !params[:sort].blank? ? {params[:sort].to_sym=>params[:order]} : {:is_top=>"desc",:postdate=>"desc"})
|
||||
|
||||
# announcements = Bulletin.where(:title.ne => "" ,:is_preview.in=>[false,nil]).can_display.is_approved.order_by(sort).filter_by_categories.filter_by_tags(OrbitHelper.page_tags)
|
||||
if OrbitHelper.page_categories.first == "all"
|
||||
|
|
Reference in New Issue