Module: CamaleonCms::Frontend::SeoHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/camaleon_cms/frontend/seo_helper.rb

Instance Method Summary collapse

Instance Method Details

#cama_seo_settings(options) ⇒ Object

permit to define seo attributes by code without hooks (check here for more attributes: https://github.com/kpumuk/meta-tags) @Sample: cama_seo_settings( "my custom title", description: "my descr", keywords: "my keywords", image: 'my img url' ) This values will be shown within the_head(...)



60
61
62
63
# File 'app/helpers/camaleon_cms/frontend/seo_helper.rb', line 60

def cama_seo_settings(options)
  CurrentRequest.frontend_seo_settings ||= {}
  CurrentRequest.frontend_seo_settings = CurrentRequest.frontend_seo_settings.merge(options)
end

#cama_the_seo(data = {}) ⇒ Object

add seo attributes to your page you can pass custom data to overwrite default data generated by the system return hash of seo attributes used by the_head(...)



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/helpers/camaleon_cms/frontend/seo_helper.rb', line 7

def cama_the_seo(data = {})
  visited_post = camaleon_frontend_visited_state(:frontend_visited_post)
  visited_post_type = camaleon_frontend_visited_state(:frontend_visited_post_type)
  visited_tag = camaleon_frontend_visited_state(:frontend_visited_tag)
  visited_category = camaleon_frontend_visited_state(:frontend_visited_category)
  visited_user = CurrentRequest.frontend_user
  visited_user ||= instance_variable_get(:@user) if instance_variable_defined?(:@user) # legacy @user (M20)

  data2 = if is_home?
            {}
          elsif is_page?
            { image: visited_post.the_thumb_url,
              title: "#{current_site.the_title} | #{visited_post.the_title}",
              description: visited_post.the_excerpt,
              keywords: visited_post.the_keywords,
              object: visited_post }
          elsif is_ajax?
            {}
          elsif is_search?
            { title: "#{current_site.the_title} | #{ct('search_title', default: 'Search')}" }
          elsif is_post_type?
            { image: visited_post_type.the_thumb_url,
              title: "#{current_site.the_title} | #{visited_post_type.the_title}",
              description: visited_post_type.the_excerpt,
              keywords: visited_post_type.the_keywords,
              object: visited_post_type }
          elsif 
            { title: "#{current_site.the_title} | #{visited_tag.the_title}",
              description: visited_tag.the_excerpt,
              keywords: visited_tag.the_keywords,
              object: visited_tag }
          elsif is_category?
            { image: visited_category.the_thumb_url,
              title: "#{current_site.the_title} | #{visited_category.the_title}",
              description: visited_category.the_excerpt,
              keywords: visited_category.the_keywords,
              object: visited_category }
          elsif is_profile?
            { image: visited_user.the_avatar, title: "#{current_site.the_title} | #{visited_user.the_name}",
              description: visited_user.the_slogan, object: visited_user }
          else
            {}
          end
  cama_build_seo(data2.merge!(camaleon_frontend_seo_settings || {}).merge(data))
end