14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/cms_lite_controller.rb', line 14
def render_content_page(cms_lite_path, request_layout = '')
content_page = nil
CmsLite.content_paths.each do |content_path|
content_page_key = params[:content_page].is_a?(Array) ? params[:content_page].join('/') : params[:content_page]
path = File.join(RAILS_ROOT, content_path, cms_lite_path, I18n.locale.to_s, params[:content_key], content_page_key)
format = params[:format] || 'htm'
content_page = Dir.glob("#{path}.#{format}").first
content_page = Dir.glob("#{path}").first if content_page.nil?
content_page = Dir.glob("#{path}.*").first if content_page.nil?
break if !content_page.nil?
end
raise CmsLite::Exceptions::MissingTemplateError, "Could not find template for: '#{cms_lite_path}'" if content_page.nil?
respond_to do |format|
format.html { render :file => content_page, :layout => choose_layout(params[:content_key]) }
format.js { render :file => content_page, :layout => false }
format.xml { render :file => content_page, :layout => false }
end
rescue CmsLite::Exceptions::MissingTemplateError => ex
render :file => "#{RAILS_ROOT}/public/404.html", :status => 404
end
|