Class: CamaleonCms::PostDefault
- Inherits:
-
CamaleonRecord
- Object
- ActiveRecord::Base
- CamaleonRecord
- CamaleonCms::PostDefault
- Includes:
- CustomFieldsRead, Metas
- Defined in:
- app/models/camaleon_cms/post_default.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#draft_id ⇒ Object
attr_accessible :user_id, :title, :slug, :content, :content_filtered, :status, :visibility, :visibility_value, :post_order, :post_type_key, :taxonomy_id, :published_at, :post_parent, :post_order, :is_feature.
Class Method Summary collapse
-
.find_by_slug(slug) ⇒ Object
find a content by slug (support multi language).
- .inherited(subclass) ⇒ Object
Instance Method Summary collapse
-
#author ⇒ Object
return the author of this Content.
-
#in_nav_menu_items ⇒ Object
return all menu items in which this post was assigned.
-
#parent ⇒ Object
return the parent of a post (support for sub contents or tree of posts).
-
#set_params(meta, custom_fields, options) ⇒ Object
Set the meta, field values and the post keywords here.
Methods included from CustomFieldsRead
#add_custom_field_group, #add_custom_field_to_default_group, #get_field_groups, #get_field_object, #get_field_value, #get_field_values, #get_field_values_hash, #get_fields_grouped, #get_fields_object, #get_user_field_groups, #save_field_value, #set_field_value, #set_field_values, #update_field_value
Methods included from Metas
#delete_meta, #delete_option, #fix_save_metas_options_no_changed, #get_meta, #get_option, #options, #save_metas_options, #save_metas_options_skip, #set_meta, #set_metas, #set_option, #set_options
Methods inherited from CamaleonRecord
#cama_build_cache_key, #cama_fetch_cache, #cama_get_cache, #cama_remove_cache, #cama_set_cache
Instance Attribute Details
#draft_id ⇒ Object
attr_accessible :user_id, :title, :slug, :content, :content_filtered, :status, :visibility, :visibility_value, :post_order, :post_type_key, :taxonomy_id, :published_at, :post_parent, :post_order, :is_feature
17 18 19 |
# File 'app/models/camaleon_cms/post_default.rb', line 17 def draft_id @draft_id end |
Class Method Details
.find_by_slug(slug) ⇒ Object
find a content by slug (support multi language)
38 39 40 41 42 43 44 45 46 |
# File 'app/models/camaleon_cms/post_default.rb', line 38 def self.find_by_slug(slug) # if current_site.present? && current_site.get_meta("languages_site", []).count <= 1 # res = self.where(slug: slug) # else res = where("#{CamaleonCms::Post.table_name}.slug = ? OR #{CamaleonCms::Post.table_name}.slug LIKE ? ", slug, "%-->#{slug}<!--%") # end res.take end |
.inherited(subclass) ⇒ Object
6 7 8 9 10 11 12 |
# File 'app/models/camaleon_cms/post_default.rb', line 6 def self.inherited(subclass) super subclass.class_eval do include CamaleonCms::CommonRelationships end end |
Instance Method Details
#author ⇒ Object
return the author of this Content
54 55 56 57 58 |
# File 'app/models/camaleon_cms/post_default.rb', line 54 def CamaleonCms::User.find(user_id) rescue StandardError CamaleonCms::User.admin_scope.first end |
#in_nav_menu_items ⇒ Object
return all menu items in which this post was assigned
61 62 63 |
# File 'app/models/camaleon_cms/post_default.rb', line 61 def CamaleonCms::NavMenuItem.where(url: id, kind: 'post') end |
#parent ⇒ Object
return the parent of a post (support for sub contents or tree of posts)
49 50 51 |
# File 'app/models/camaleon_cms/post_default.rb', line 49 def parent CamaleonCms::Post.where(id: post_parent).first end |
#set_params(meta, custom_fields, options) ⇒ Object
Set the meta, field values and the post keywords here
66 67 68 69 70 |
# File 'app/models/camaleon_cms/post_default.rb', line 66 def set_params(, custom_fields, ) () set_field_values(custom_fields) () end |