fix MORE bug

This commit is contained in:
Ruling-Mac 2015-07-28 17:37:23 +08:00
parent 499f389da5
commit 6e9b1613bf
1 changed files with 13 additions and 3 deletions

View File

@ -114,7 +114,7 @@ class NewsController < ApplicationController
ma = ModuleApp.find_by_key("news") rescue nil ma = ModuleApp.find_by_key("news") rescue nil
current_categories = OrbitHelper.widget_categories 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) if current_categories.include?(cat.id.to_s)
{ {
"name" => cat.title, "name" => cat.title,
@ -122,8 +122,17 @@ class NewsController < ApplicationController
} }
end end
end end
categories.delete(nil) categories_for_url.delete(nil)
categories = {"name" => t("news.all"), "category-link" => "/#{I18n.locale.to_s + page.url}/"} if categories.count != 1 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| anns = news.collect do |a|
if a.image_description.blank? if a.image_description.blank?
@ -159,6 +168,7 @@ class NewsController < ApplicationController
{ {
"news" => anns, "news" => anns,
"categories" => categories, "categories" => categories,
"categories_for_url" => categories_for_url,
"extras" => { "extras" => {
"more_url"=>OrbitHelper.widget_more_url, "more_url"=>OrbitHelper.widget_more_url,
"title-head" => t('news.table.title'), "title-head" => t('news.table.title'),