Setting
Last updated
Last updated
A section
or block
definition comes with a list of settings
. Those settings will be used by the editor UI to render the proper content form of a section (or block).
For instance, if your section includes 2 settings, let's say a title (text) and a background image (image), then the editor UI will generate for this section a form with 2 input elements: a text input for the input and an image picker to select the background image.
Display a text input, simple or a rich text editor depending on the setting options.
Definition:
Usage in the HTML/ERB template:
Display an image picker to let the content editor choose or upload any image.
Definition:
Usage in the HTML/ERB template:
List of properties:
Display a link picker. The content editor will have the choice between a link to an external URL, a page or an email address.
Definition:
Usage in the HTML/ERB template:
List of properties:
This setting type allows content editors to select an instance of any ActiveRecord class of the main Ruby on Rails application. For instance, in your e-commerce site, if your section is named featured_product_01
, chances are big that you will need a collection_item
setting type to let your editors pick the product of their choice among the products
table.
Definition:
Usage in the HTML/ERB template:
If the content editor hasn't chosen an item or if the item doesn't exist anymore, the setting tag won't rendered.
List of properties:
Display a color picker. The content editor will have to choose between a selection of color presets defined by the developer.
Definition:
Usage in the HTML/ERB template:
List of properties:
Display a toggle input.
Definition:
Usage in the HTML/ERB template:
List of properties:
Display a popup to select an icon among a set of icons. Follow the instructions here to set up the icon library.
Definition:
Usage in the HTML/ERB template:
Name
Type
Description
label
string
Label displayed in the editor UI as the input label.
id
string
Identifier of the section. Required when you want to display the value of the setting inside the HTML template of the section or block. It has to be unique among the settings of a section.
type
string
Describe which kind of input the editor UI will render. See below for a list of available types.
default
string
When a section or a block is added to the page, in order to avoid blank content, Maglev will fill the section or block content with the default value of each setting.
A value is required.
advanced
boolean
If the setting is not content related, the editor UI will put this setting in a different tab in the section form.
Option
Type
Description
html
boolean
Enable the rich text editor for this setting. False by default.
line_break
boolean
If true (and if the html
option is also true), will cause the carriage return (enter key) to generate a <br>
tag instead of closing the current element. False by default
nb_rows
integer
Number of rows for the rich text editor.
Property
Type
Description
url
string
Url of the image
width
integer
Width of the original image (in px)
height
integer
Height of the original image (in px)
alt_text
string
Alternate text added by the content editor
to_s
string
Alias of the url
method
Option
Type
Description
with_text
Boolean
False if the developer only needs an url. Otherwise, the editor UI will present a text field in addition on the URL picker.
Property
Type
Description
href
String
URL of the page / external URL / email address.
text
String
Text typed by the content editor (if functionality enabled by the with_text
option.
open_new_window?
Boolean
True if the content editor wants the link to be opened in a new browser tab.
target_blank
String
Returns _blank
or nil depending on the property above.
to_s
String
Alias of the href
property.
Option
Type
Description
collection_id
String
ID of the collection as set up in theme.yml file
Property
Type
Description
exists?
Boolean
True if the collection item exists in DB.
item
Model
The collection item loaded from the DB.
Option
Type
Description
presets
Array of strings
List of hexadecimal colors.
Property
Type
Description
dark?
Boolean
True if the brightness
index of this color is less than 128.
light?
Boolean
True if the brightness
index of this color is great than 155.
brightness
Integer
Value between 0 and 255.
Property
Type
Description
true?
Boolean
false?
Boolean