From 499f389da56de77f628658d4edd48bb530f16e97 Mon Sep 17 00:00:00 2001 From: Ruling-Mac Date: Tue, 28 Jul 2015 17:13:44 +0800 Subject: [PATCH] modify news url about category --- app/controllers/news_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 5cab1af..2c8cafc 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -112,14 +112,18 @@ class NewsController < ApplicationController page = Page.where(:module => "news").first rescue nil ma = ModuleApp.find_by_key("news") rescue nil + + current_categories = OrbitHelper.widget_categories categories = ma.categories.enabled.collect do |cat| + if current_categories.include?(cat.id.to_s) { "name" => cat.title, "category-link" => "/#{I18n.locale.to_s + page.url}/?category=#{cat.to_param}" } + end end - - categories.unshift({"name" => t("news.all"), "category-link" => "/#{I18n.locale.to_s + page.url}/"}) + categories.delete(nil) + categories = {"name" => t("news.all"), "category-link" => "/#{I18n.locale.to_s + page.url}/"} if categories.count != 1 anns = news.collect do |a| if a.image_description.blank? @@ -140,8 +144,6 @@ class NewsController < ApplicationController elsif I18n.locale.to_s == 'en' subtitle = a.subtitle.truncate(200) end - - { "title" => HTMLEntities.new.encode(a.title),