31 lines
843 B
Ruby
31 lines
843 B
Ruby
module Admin::ActivesHelper
|
|
def page_for_act(active=nil)
|
|
ann_page = nil
|
|
pages = Page.where(:module=>'active')
|
|
|
|
pages.each do |page|
|
|
if page.categories.count ==1
|
|
if page.categories.include?(active.category.id.to_s)
|
|
ann_page = page
|
|
end
|
|
end
|
|
break if !ann_page.nil?
|
|
end
|
|
|
|
if ann_page.nil?
|
|
pages.each do |page|
|
|
if page.categories.include?(active.category.id.to_s)
|
|
ann_page = page
|
|
end
|
|
break if !ann_page.nil?
|
|
end
|
|
end
|
|
|
|
ann_page = pages.first if ann_page.nil?
|
|
if !active.blank?
|
|
request.protocol+(request.host_with_port+ann_page.url+'/'+active.to_param).gsub('//','/') rescue "/"
|
|
else
|
|
request.protocol+(request.host_with_port+'/'+I18n.locale.to_s+ann_page.url+'/').gsub('//','/') rescue "/"
|
|
end
|
|
end
|
|
end |