Module: CamaleonCms::Frontend::ContentSelectHelper

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

Instance Method Summary collapse

Instance Method Details

#each_category_of(post_type_slug, options = {}) ⇒ Object

loop through each category of post type each_category_of(‘post’) do

the_title

end

each_category_of(‘post’, limit: 4) do

the_title

end



140
141
142
143
144
145
146
147
148
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 140

def each_category_of(post_type_slug, options = {})
  the_post_type(post_type_slug) do
    the_categories(options).each do |category|
      process_in_block(category) do
        yield(category) if block_given?
      end
    end
  end
end

#each_post_of(post_type_slug, options = {}) ⇒ Object

loop through each post of post type each_post_of(‘post’) do

the_title

end

each_post_of(‘post’, limit: 10) do

the_title

end



122
123
124
125
126
127
128
129
130
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 122

def each_post_of(post_type_slug, options = {})
  the_post_type(post_type_slug) do
    the_posts(options).each do |post|
      process_in_block(post) do
        yield(post) if block_given?
      end
    end
  end
end

#process_in_block(object) ⇒ Object

allow object to be global varaible in block work_in_block_of(post) do

the_field('extra-content')

end



154
155
156
157
158
159
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 154

def process_in_block(object)
  temp_object = @object
  @object     = object
  yield
  @object = temp_object
end

#the_comments(options = {}) ⇒ Object

select comments of post the_post(‘blog’)

the_comments

end



54
55
56
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 54

def the_comments(options = {})
  @object.comments.limit(options[:limit]).decorate if @object.present?
end

#the_contentObject

select content of post the_post(‘blog’) do

the_content

end



70
71
72
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 70

def the_content
  @object.the_content.html_safe if @object.present?
end

#the_excerpt(chars = 200) ⇒ Object

select excerpt of post the_post(‘blog’) do

the_excerpt

end



102
103
104
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 102

def the_excerpt(chars = 200)
  @object.the_excerpt(chars) if @object.present?
end

#the_field(slug) ⇒ Object

select custome field from object the_post(‘blog’) do

the_field('extra-content')

end



110
111
112
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 110

def the_field(slug)
  @object.the_field(slug) if @object.present?
end

#the_post(slug) ⇒ Object

select single post of post type the_post_type(‘post’) do

the_post('first-blog-post')

end



14
15
16
17
18
19
20
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 14

def the_post(slug)
  post = @object.the_post(slug)
  process_in_block(post) do
    yield(post) if block_given?
  end
  post
end

#the_post_type(slug) ⇒ Object

select post type by just pass slug to parameter Example: the_post_type(‘post’) the_post_type(‘page’)

the_post_type(‘post’) do

the_post('first-blog')

end



42
43
44
45
46
47
48
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 42

def the_post_type(slug)
  post_type = current_site.the_post_type(slug)
  process_in_block(post_type) do
    yield(post_type) if block_given?
  end
  post_type
end

#the_posts(options = {}) ⇒ Object

select posts of post type the_post_type(‘post’) do

the_posts

end

the_post_type(‘post’) do

the_posts(limit: 10)

end



30
31
32
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 30

def the_posts(options = {})
  @object.posts.visible_frontend.limit(options[:limit]).decorate
end

#the_slugObject

select slug of post, post type … (@object) the_post(‘blog’) do

the_slug

end



94
95
96
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 94

def the_slug
  @object.the_slug if @object.present?
end

#the_thumbnailObject

select thumbnail of post the_post(‘blog’) do

the_thumbnail

end



86
87
88
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 86

def the_thumbnail
  @object.the_thumb_url if @object.present?
end

#the_titleObject

select title of post the_post(‘blog’) do

the_title

end



62
63
64
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 62

def the_title
  @object.the_title if @object.present?
end

#the_urlObject

select url of post the_post(‘blog’) do

the_url

end



78
79
80
# File 'app/helpers/camaleon_cms/frontend/content_select_helper.rb', line 78

def the_url
  @object.the_url if @object.present?
end