Module: PagesCms::ApplicationHelper

Included in:
ContactsController
Defined in:
app/helpers/pages_cms/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#blog_path(current_site, search = '') ⇒ Object

redirects to the blog with a search



27
28
29
30
31
32
# File 'app/helpers/pages_cms/application_helper.rb', line 27

def blog_path(current_site, search = '')
  blog = current_site.pages.find_by(slug: 'blog')
  unless blog.nil?
    "#{slugged_path(blog)}?search=#{search}"
  end
end

#current_accountObject



4
5
6
7
8
9
10
# File 'app/helpers/pages_cms/application_helper.rb', line 4

def 
  if .exists?(session[:current_account])
    .find(session[:current_account])
  else
    false
  end
end

#current_siteObject



46
47
48
49
50
51
52
53
54
# File 'app/helpers/pages_cms/application_helper.rb', line 46

def current_site
  if params[:account]
    .where(id: params[:account]).first
  elsif session[:current_account]
    .where(id: session[:current_account]).first
  else
    false
  end
end

#insert_html_breaks(string) ⇒ Object



34
35
36
# File 'app/helpers/pages_cms/application_helper.rb', line 34

def insert_html_breaks(string)
  string.gsub(/\n/, '<br />')
end

#meta_descriptionObject



42
43
44
# File 'app/helpers/pages_cms/application_helper.rb', line 42

def meta_description

end

#meta_tagsObject



38
39
40
# File 'app/helpers/pages_cms/application_helper.rb', line 38

def meta_tags

end

#pages_cms_auth_exists?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'app/helpers/pages_cms/application_helper.rb', line 56

def pages_cms_auth_exists?
  defined?(PagesCmsAuth) == 'constant'
end

#slugged_path(page) ⇒ Object

added by PagesCMS. Use this helper to link to user created pages.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/pages_cms/application_helper.rb', line 13

def slugged_path(page)
  if page.class == String
    "/#{page}"                            # if passes a string, just add a slash
  else
    mount = page..mount_location
    if mount == '/'
      "/#{page.slug}"                     # don't want the link to look like this '///home'
    else
      "/#{mount}/#{page.slug}"            # if the mount location is normal. ie. '/site/home'
    end
  end
end