Module: CamaleonCms::Frontend::ContentSelectHelper

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

Overview

Camaleon CMS is a content management system

Copyright (C) 2015 by Owen Peredo Diaz
Email: [email protected]
This program is free software: you can redistribute it and/or modify   it under the terms of the GNU Affero General Public License as  published by the Free Software Foundation, either version 3 of the  License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the  GNU Affero General Public License (GPLv3) for more details.

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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

#the_thumbnailObject

select thumbnail of post the_post(‘blog’) do

the_thumbnail

end



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

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

#the_titleObject

select title of post the_post(‘blog’) do

the_title

end



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

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

#the_urlObject

select url of post the_post(‘blog’) do

the_url

end



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

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