1 # A section is an organizational unit for content nodes.
3 # Sections can be applied to pages or snippets, but really are
4 # only meant for blogs.
8 include DataMapper::Persistable
9 include DataMapper::Is::Tree
11 has_and_belongs_to_many :content_nodes
12 has_and_belongs_to_many :blogs,
13 :join_table => 'content_nodes_sections',
14 :association_foreign_key => 'content_node_id',
15 :conditions => "content_nodes.type = 'Blog'",
16 :order => 'display_on DESC'
18 property :name, :string, :length => 100, :default => "", :nullable => false
19 property :rank, :integer
20 #property :parent_id -->
22 #validates_presence_of :name
23 #validates_uniqueness_of :name
24 is_a_tree :order => 'rank' # '-rank DESC'
26 # Most used finder function for tags.
27 # Selects by alpha sort.
29 all #:order => 'name ASC')
32 # Finds ordered parent tags.
33 def self.find_ordered_parents
34 all(:conditions => "parent_id IS NULL OR parent_id = 0")
35 #:order => "-rank DESC"
38 # Returns the number of products tagged with this item
40 @cached_content_count ||= self.content_nodes.count