fix announcement count
This commit is contained in:
parent
00e62d3363
commit
710366377c
|
@ -8,13 +8,13 @@ class AnnouncementsController < ApplicationController
|
||||||
if params[:keywords]
|
if params[:keywords]
|
||||||
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:is_top=>"desc",: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 = 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
|
announcements_count = ",共有" + announcements.count.to_s + "筆資料"
|
||||||
keyword = "搜尋標題有關 ' " + params[:keywords] + " '"
|
keyword = "搜尋標題有關 ' " + params[:keywords] + " '"
|
||||||
|
|
||||||
elsif params[:unit]
|
elsif params[:unit]
|
||||||
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:is_top=>"desc",: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 = 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
|
announcements_count = ",共有" + announcements.count.to_s + "筆資料"
|
||||||
keyword = "列出由:" + params[:unit] + "發佈的資料"
|
keyword = "列出由:" + params[:unit] + "發佈的資料"
|
||||||
|
|
||||||
elsif params[:tag]
|
elsif params[:tag]
|
||||||
|
@ -26,7 +26,7 @@ class AnnouncementsController < ApplicationController
|
||||||
!params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:is_top=>"desc",: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
|
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 = Bulletin.all.where(:title.ne => "").is_approved.order_by(sort).filter_by_categories([category.id.to_s]) if !category.nil?
|
||||||
announcements_count = announcements.count
|
announcements_count = ",共有" + announcements.count.to_s + "筆資料"
|
||||||
|
|
||||||
keywords = params[:category].split("-")
|
keywords = params[:category].split("-")
|
||||||
keywords.delete(keywords.last)
|
keywords.delete(keywords.last)
|
||||||
|
|
Reference in New Issue