Class: Decidim::ContentBlockManifest

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
decidim-core/lib/decidim/content_block_manifest.rb

Overview

This class acts as a manifest for content blocks.

A content block is a view section in a given page. Those sections can be registered by Decidim modules, and are configurable and sortable. They are a useful way to customize a given page, without having to rely on overwriting the views files. Also, this system is more powerful than basic view hooks (see the `ViewHooks` class for reference), as view hooks don't have a way to explicitly control the order of the hooked views.

Content blocks are intended to be used in the home page, for example.

A content block has a set of settings and an associated `cell` that will handle the layout logic. They can also have attached images that can be used as background images, for example. You must explicitly specify the number of images the block will have (this means the number of attached images cannot be configurable). Each content block is identified by a name, which has to be unique per scope.

Instance Method Summary collapse

Instance Method Details

#default!Object

Public: Registers whether this content block should be shown by default when creating an organization. Use `#default` to retrieve it.


39
40
41
# File 'decidim-core/lib/decidim/content_block_manifest.rb', line 39

def default!
  self.default = true
end

#has_settings?Boolean

Returns:

  • (Boolean)

43
44
45
# File 'decidim-core/lib/decidim/content_block_manifest.rb', line 43

def has_settings?
  settings.attributes.any?
end

#settings {|@settings| ... } ⇒ Object

Yields:


47
48
49
50
51
# File 'decidim-core/lib/decidim/content_block_manifest.rb', line 47

def settings(&block)
  @settings ||= SettingsManifest.new
  yield(@settings) if block
  @settings
end