Class: CmsLiteController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/cms_lite_controller.rb

Instance Method Summary collapse

Instance Method Details

#render_content_page(cms_lite_path, request_layout = '') ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/cms_lite_controller.rb', line 13

def render_content_page(cms_lite_path, request_layout = '')
  path = File.join(RAILS_ROOT, CmsLite::CMS_LITE_CONTENT_PATH, cms_lite_path, I18n.locale.to_s, params[:content_key], params[:content_page].join('/'))
  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?
  raise CmsLiteExceptions::MissingTemplateError, "Could not find template for: '#{path}'" if content_page.nil?
  respond_to do |format|
    format.html { render :file => content_page }
    format.js { render :file => content_page, :layout => false }
    format.xml { render :file => content_page, :layout => false }
  end
rescue CmsLiteExceptions::MissingTemplateError => ex
  
  render :file => "#{RAILS_ROOT}/public/404.html", :status => 404
end

#show_pageObject



5
6
7
# File 'app/controllers/cms_lite_controller.rb', line 5

def show_page
  render_content_page(CmsLite::CMS_LITE_PAGES_PATH)
end

#show_protected_pageObject



9
10
11
# File 'app/controllers/cms_lite_controller.rb', line 9

def show_protected_page
  render_content_page(CmsLite::CMS_LITE_PROTECTED_PAGES_PATH)
end