Fix read more page bug.

This commit is contained in:
BoHung Chiu 2021-08-20 09:21:25 +08:00
parent 146909c0c2
commit 0bd3f04c31
1 changed files with 14 additions and 6 deletions

View File

@ -190,8 +190,16 @@ class AnnouncementsController < ApplicationController
end
[cat_id,t]
}.to_h
page = Page.where(:page_id=> subpart.read_more_page_id).first rescue nil
page = Page.where(:module => "announcement").first rescue nil if page.nil?
home_page = Page.first
page = nil
locale = I18n.locale.to_s
if home_page.respond_to?(:find_page)
page = home_page.find_page(:page_id=> subpart.read_more_page_id,:enabled_for=>locale).first rescue nil
page = home_page.find_page(:module=>"announcement",:enabled_for=>locale).first rescue nil if page.nil?
else
page = Page.where(:page_id=> subpart.read_more_page_id,:enabled_for=>locale).first rescue nil
page = Page.where(:module=>"announcement",:enabled_for=>locale).first rescue nil if page.nil?
end
all_cats = cats.dup
all_cats.delete "all"
if all_cats.count == 0
@ -208,7 +216,7 @@ class AnnouncementsController < ApplicationController
"<div style=\"clear: both;\"></div>" +
"<ul class=\"nav_tabs_filter\">" +
(use_tag ? tags.map.with_index{|tag,i|
read_more_url = "/#{I18n.locale.to_s + page.url}" rescue ""
read_more_url = "/#{locale + page.url}" rescue ""
read_more_url = read_more_url + "?" + {"category"=>all_cats,"tags"=>(tag == 'all' ? all_tags : [tag])}.to_param if read_more_url != ""
read_more_text = I18n.t("announcement.more")
if tag != "all"
@ -220,7 +228,7 @@ class AnnouncementsController < ApplicationController
end
"<li class=\"filter_tab#{i == 0 ? ' active' : ''}\" #{(tag == 'all' && @all_setting_option == 0) ? "data-count_limit=\"#{max_all_count}\"" : ''} data-read_more_text=\"#{read_more_text}\" data-read_more=\"#{read_more_url}\" data-tags=\"#{tag}\">#{tags_translations[tag]}</li>"
}.join("") : cats.map.with_index{|cat,i|
read_more_url = "/#{I18n.locale.to_s + page.url}" rescue ""
read_more_url = "/#{locale + page.url}" rescue ""
read_more_url = read_more_url + "?" + {"category"=>(cat == 'all' ? all_cats : cat)}.to_param if read_more_url != ""
read_more_text = I18n.t("announcement.more")
if cat != "all"
@ -363,7 +371,7 @@ class AnnouncementsController < ApplicationController
"
end
if @tab_option == 0
read_more_url = "/#{I18n.locale.to_s + page.url}" rescue ""
read_more_url = "/#{locale + page.url}" rescue ""
read_more_url = read_more_url + "?" + {"category"=>all_cats,"tags"=>all_tags}.to_param if read_more_url != ""
extra_after_html += "
<script>
@ -374,7 +382,7 @@ class AnnouncementsController < ApplicationController
{
"announcements" => anns,
"extras" => {
"more_url"=>OrbitHelper.widget_more_url,
"more_url"=>read_more_url,
"main_picture" => mp,
"main_picture_description" => mpd,
"title-head" => t('announcement.table.title'),