From 6e9b1613bf063dae9f7666f6062c8df32c9392ba Mon Sep 17 00:00:00 2001 From: Ruling-Mac Date: Tue, 28 Jul 2015 17:37:23 +0800 Subject: [PATCH] fix MORE bug --- app/controllers/news_controller.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 2c8cafc..0b824fc 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -114,7 +114,7 @@ class NewsController < ApplicationController ma = ModuleApp.find_by_key("news") rescue nil current_categories = OrbitHelper.widget_categories - categories = ma.categories.enabled.collect do |cat| + categories_for_url = ma.categories.enabled.collect do |cat| if current_categories.include?(cat.id.to_s) { "name" => cat.title, @@ -122,8 +122,17 @@ class NewsController < ApplicationController } end end - categories.delete(nil) - categories = {"name" => t("news.all"), "category-link" => "/#{I18n.locale.to_s + page.url}/"} if categories.count != 1 + categories_for_url.delete(nil) + categories_for_url = {"name" => "ALL", "category-link" => "/#{I18n.locale.to_s + page.url}/"} if categories_for_url.count != 1 + + categories = ma.categories.enabled.collect do |cat| + { + "name" => cat.title, + "category-link" => "/#{I18n.locale.to_s + page.url}/?category=#{cat.to_param}" + } + end + + categories.unshift({"name" => t("news.all"), "category-link" => "/#{I18n.locale.to_s + page.url}/"}) anns = news.collect do |a| if a.image_description.blank? @@ -159,6 +168,7 @@ class NewsController < ApplicationController { "news" => anns, "categories" => categories, + "categories_for_url" => categories_for_url, "extras" => { "more_url"=>OrbitHelper.widget_more_url, "title-head" => t('news.table.title'),