Section
A section
belongs to a theme and a category.
When an content editor adds a section within a page, Maglev creates an unique instance of the section based on its definition. This instance will store the content (text / image / links / ...etc) written by the content editor.
The section definition tells to the Editor UI how to build the content form.
When you genarate a new section through a Rails generator, you end up with the following folder structure.
The id of a section is the base name of their definition file name. Example: heroe_01 for heroe_01.yml.
Definition file
Attribute name | Type | Description |
name | string | Name of the section (displayed in the editor UI) |
category | string | Identifier of the category (declared in the theme.yml file) |
site_scoped | boolean | A section might have the same content all over the site, like a menu or a footer for instance. False by default. |
singleton | boolean | Indicate if there should be one single instance of this section in a page. False by default. |
viewport_fixed_position | boolean | If the sections has a |
insert_at | string |
|
insert_button | boolean | Display or not the insert section icon at the bottom of the section. By default, |
settings | array of settings | List of settings (title, background image, ...etc). See the next chapter to see how to define settings. |
blocks | array of blocks | List of block definitions. |
blocks_label | string | Name of the list of blocks in the UI editor. For instance, if you built a section to represent the menu of your site, you will name them "Menu items". By default: "Blocks" |
blocks_presentation | string | Possible values: |
Template
Inside your section template file, you'll have access to a variable named maglev_section
exposing the content written by the editors.
This variable owns a couple of attributes / methods.
Attribute / Method | Type | Description |
wrapper_tag | Display the wrapping HTML tag with the information required by the editor UI. To use a tag other than DIV, you can write:
| |
setting_tag | Display the content of the setting. The first argument is the id of your setting. Based on the setting type, it will render a specific HTML content. | |
blocks | Array | List of blocks |
The section must be wrapped by a single HTML node (DIV, SECTION, ...etc). This node will carry some important information about the section required by the UI editor. Those information are very important in order to refresh its content.
You've got also the ability to not use our helpers and write plain HTML code instead. The example above can be also written like the following way:
Last updated