Module: Ecm::CmsCoreHelper

Included in:
Ecm::CmsCore::PageController
Defined in:
app/helpers/ecm/cms_core_helper.rb

Instance Method Summary collapse

Instance Method Details

#cms_body_classesObject



2
3
4
# File 'app/helpers/ecm/cms_core_helper.rb', line 2

def cms_body_classes
  url_for().gsub("/", " ").strip!
end

#cms_meta_descriptionObject



26
27
28
# File 'app/helpers/ecm/cms_core_helper.rb', line 26

def cms_meta_description
  @meta_description
end

#cms_meta_description_tagObject



30
31
32
# File 'app/helpers/ecm/cms_core_helper.rb', line 30

def cms_meta_description_tag
  "<meta name=\"description\" content=\"#{cms_meta_description}\" />".html_safe
end

#cms_page_stylesheets(namespace = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/ecm/cms_core_helper.rb', line 6

def cms_page_stylesheets(namespace = nil)
  output = ""
  if namespace
    namespace_string = "#{namespace}/"
  else
    namespace_string = ""
  end
  url_for().split("/").each do |path_part|
    output << stylesheet_link_tag("#{namespace_string}#{path_part}.css", :media => 'screen') unless path_part.blank? || path_part.length == 1
  end
  output.html_safe
end

#cms_title(site_title = nil) ⇒ Object

Displays the site title



20
21
22
23
24
# File 'app/helpers/ecm/cms_core_helper.rb', line 20

def cms_title(site_title = nil)
  site_title ||= Rails.application.class.to_s.split("::").first.titleize
  return "#{site_title} - #{@title}" if @title
  site_title
end

#render_fragment(name) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/helpers/ecm/cms_core_helper.rb', line 34

def render_fragment(name)
  if controller_name == 'page'
    page = (params[:page].nil?) ? "home" : params[:page]
  else
    page = request.fullpath.gsub(/\/#{I18n.locale}\//, '')
  end  
  
  path = "#{name.to_s}/#{page}"
  full_path = "#{I18n.locale}/#{path}"

  begin 
    render path
  rescue ActionView::MissingTemplate => e
    if Rails.env.production?
      return nil
    else 
      return I18n.t("ecm.cms_core.warnings.missing_fragment", :name => full_path)
    end        
  end  
end