event_ann/app/views/event_anns/show.html.erb

54 lines
2.2 KiB
Plaintext

<%
require 'event_anns_helper'
params = OrbitHelper.params
page = Page.where(url:params['url']).first
@show_back_and_next_flag = 0
if page.methods.include? 'select_option_items'.to_sym
ModuleApp.all.select{|tmp| tmp.key.to_s=='event_ann'}.each do |modile_app|
@show_option_items = modile_app.show_option_items rescue nil
end
page.select_option_items.each do |select_option_item|
if !(@show_option_items.nil?) && select_option_item.field_name == @show_option_items.keys.first.to_s
value = YAML.load(select_option_item.value)
tmp = value[:en]
I18n.with_locale(:en) do
if tmp == t('event_ann.not_show')
@show_back_and_next_flag = 0
elsif tmp == t('event_ann.show_top')
@show_back_and_next_flag = 1
elsif tmp == t('event_ann.show_bottom')
@show_back_and_next_flag = 2
end
end
end
end
end
if @show_back_and_next_flag != 0
uid = params['uid']
sorted,total_pages = get_sorted_event_ann(0)
now_index = sorted.to_enum.with_index.select{|v| v[0].uid==uid}[0][1] rescue nil
if !now_index.nil?
if now_index != 0
prev_result = sorted[now_index-1]
prev_url = params['url'] + '/' + prev_result.to_param
prev_content = "<button href='#{prev_url}' title='#{t('event_ann.prev')}' class='prev btn btn-default pull-left col-sm-5 btn-sm'><b>#{t('event_ann.prev')}</b><p>#{prev_result['title'][I18n.locale]}</p></button>"
end
if now_index != sorted.length-1
next_result = sorted[now_index+1]
next_url = params['url'] + '/' + next_result.to_param
next_content = "<button href='#{next_url}' title='#{t('event_ann.next')}' class='next btn btn-default pull-right col-sm-5 btn-sm'><b>#{t('event_ann.next')}</b><p>#{next_result['title'][I18n.locale]}</p></button>"
end
content = "<div class='see_more_boxTitle row justify-content-between'>#{prev_content}#{next_content}</div>".html_safe
else
content = ''
end
end
%>
<% if @show_back_and_next_flag==1 %>
<%= content %>
<% end %>
<%= render_view %>
<% if @show_back_and_next_flag==2 %>
<%= content %>
<% end %>