Class: Comfy::Cms::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Comfy::Cms::Page
- Defined in:
- app/models/comfy/cms/page.rb
Class Method Summary collapse
-
.options_for_select(site, page = nil, current_page = nil, depth = 0, exclude_self = true, spacer = '. . ') ⇒ Object
– Class Methods ——————————————————– Tree-like structure for pages.
Instance Method Summary collapse
-
#full_path ⇒ Object
– Instance Methods —————————————————– For previewing purposes sometimes we need to have full_path set.
-
#identifier ⇒ Object
Somewhat unique method of identifying a page that is not a full_path.
-
#url ⇒ Object
Full url for a page.
Class Method Details
.options_for_select(site, page = nil, current_page = nil, depth = 0, exclude_self = true, spacer = '. . ') ⇒ Object
– Class Methods ——————————————————– Tree-like structure for pages
47 48 49 50 51 52 53 54 55 |
# File 'app/models/comfy/cms/page.rb', line 47 def self.(site, page = nil, current_page = nil, depth = 0, exclude_self = true, spacer = '. . ') return [] if (current_page ||= site.pages.root) == page && exclude_self || !current_page out = [] out << [ "#{spacer*depth}#{current_page.label}", current_page.id ] unless current_page == page current_page.children.each do |child| out += (site, page, child, depth + 1, exclude_self, spacer) end if current_page.children_count.nonzero? return out.compact end |
Instance Method Details
#full_path ⇒ Object
– Instance Methods —————————————————– For previewing purposes sometimes we need to have full_path set. This full path take care of the pages and its childs but not of the site path
60 61 62 |
# File 'app/models/comfy/cms/page.rb', line 60 def full_path self.read_attribute(:full_path) || self.assign_full_path end |
#identifier ⇒ Object
Somewhat unique method of identifying a page that is not a full_path
65 66 67 |
# File 'app/models/comfy/cms/page.rb', line 65 def identifier self.parent_id.blank?? 'index' : self.full_path[1..-1].slugify end |
#url ⇒ Object
Full url for a page
70 71 72 |
# File 'app/models/comfy/cms/page.rb', line 70 def url "//" + "#{self.site.hostname}/#{self.site.path}/#{self.full_path}".squeeze("/") end |