Module: Cms::Concerns::GenericSitemapBehavior

Defined in:
lib/cms/concerns/can_be_addressable.rb

Overview

Implements behavior for displaying content blocks that should appear in the sitemap.

Instance Method Summary collapse

Instance Method Details

#assign_parent_if_neededObject



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/cms/concerns/can_be_addressable.rb', line 82

def assign_parent_if_needed
  unless parent || parent_id
    new_parent = Cms::Section.with_path(self.class.path).first

    unless new_parent
      logger.warn "Creating default section for #{self.try(:display_name)} in #{self.class.path}."
      section_attributes = {:name => self.class.name.demodulize.pluralize,
                            :path => self.class.path,
                            :hidden => true,
                            allow_groups: :all}
      section_parent = Cms::Section.root.first
      if section_parent
        section_attributes[:parent] = section_parent
      end
      new_parent = Cms::Section.create!(section_attributes)
    end
    self.parent_id = new_parent.id
  end
end

#hidden?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/cms/concerns/can_be_addressable.rb', line 78

def hidden?
  false
end

#partial_forObject



74
75
76
# File 'lib/cms/concerns/can_be_addressable.rb', line 74

def partial_for
  "addressable_content_block"
end