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).
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
9 10 11 |
# File 'app/models/camaleon_cms/post_default.rb', line 9 def draft_id @draft_id end |
Class Method Details
.find_by_slug(slug) ⇒ Object
find a content by slug (support multi language)
30 31 32 33 34 35 36 37 38 |
# File 'app/models/camaleon_cms/post_default.rb', line 30 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.reorder('').first end |
Instance Method Details
#author ⇒ Object
return the author of this Content
46 47 48 49 50 |
# File 'app/models/camaleon_cms/post_default.rb', line 46 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
53 54 55 |
# File 'app/models/camaleon_cms/post_default.rb', line 53 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)
41 42 43 |
# File 'app/models/camaleon_cms/post_default.rb', line 41 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
58 59 60 61 62 |
# File 'app/models/camaleon_cms/post_default.rb', line 58 def set_params(, custom_fields, ) () set_field_values(custom_fields) () end |