Sha256: b6c68f57d52abfaa9508138493b4b9600b36af17f5774369bf79867e20609034
Contents?: true
Size: 1.97 KB
Versions: 1
Compression:
Stored size: 1.97 KB
Contents
module Ecm module CmsCore class PageController < ::FrontendController include Ecm::CmsCoreHelper # append_view_path Template::Resolver.instance append_view_path Ecm::CmsCore::Template::Resolver.instance unless view_paths.include?(Ecm::CmsCore::Template::Resolver.instance) def render_404 respond_to do |format| format.html { render :file => "#{Rails.root}/public/404.html", :status => :not_found, :layout => nil } format.xml { head :not_found } format.any { head :not_found } end end def respond page, pathname, basename = extract_names_from_params if template = Template.where(:pathname => pathname).where(:basename => basename).where(:locale => I18n.locale).first @meta_description = template.meta_description @title = template.title layout = template.layout unless template.layout.nil? end begin if layout.respond_to?(:length) && layout.length > 0 render :template => page, :layout => template.layout else render :template => page end rescue ActionView::MissingTemplate render_404 end return end def extract_names_from_params page = params[:page] page ||= "/home/index" pathname = "#{I18n.locale}" subpath = page.split("/").reverse.drop(1).reverse.join("/").sub(/(\/)+$/,'') if subpath.length > 0 pathname << '/' unless subpath.start_with?('/') pathname << "#{subpath}" end pathname << '/' unless pathname.end_with?('/') basename = page.split("/").last logger.debug("pathname in page#respond: #{pathname}") logger.debug("basename in page#respond: #{basename}") logger.debug("page in page#respond: #{page}") return page, pathname, basename end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ecm_cms_core-0.0.3 | app/controllers/ecm/cms_core/page_controller.rb |