Who this is for. Content modellers designing editing forms, and developers rendering the settings that end up in attributes. After this page you can decide which areas are settings, attach a setting to the field it qualifies, and read it in a template.
What marking an area as an attribute does
A layout area with Attribute switched on stops being an ordinary field. Its editor moves behind an Attributes control, so the main form shows content and the settings wait one click away:
- on a record such as a page, attributes of the whole layout appear on their own Attributes tab;
- on a component, they open from an Attributes button on the component;
- an attribute attached to an area opens from an Attributes icon beside that area's field.
Use attributes for styling and behaviour: a background, an alignment, a width, a "hide on mobile" switch, an image's crop. Nothing changes for the template: an attribute is an area like any other, read by its own name.
Attribute of the block, or of one field
An attribute with no attachment configures the whole block. An attribute attached to an area configures that one field. The rule for choosing: would the setting still make sense if that field were empty? A section's background applies whether or not the section has an image, so it belongs to the block. An image's crop means nothing without the image, so it is attached to the image.
Attaching an attribute to an area
Set Attribute attachment on the attribute to choose the area it hangs off. Three rules, enforced on save:
- only areas that have been saved can be chosen, so save the parent area first, then attach ("Only areas that have been saved can be selected");
- the parent must not be an attribute itself ("An attribute can only be attached to a layout area that is not an attribute");
- switching Attribute off on an area clears its attachment.
An attached attribute always moves into its parent's group, and an attribute of the whole block is moved out of any group, when the layout is saved.
Worked example: an image with alt text, crop and caption
A media block whose image carries its own settings, and whose background belongs to the block:
| Area | Input type | Attribute | Attached to |
|---|---|---|---|
image | Image | No | |
imageAlt | Text | Yes | image |
imageCrop | A select: fit::Fill the frame, auto::Show the whole image | Yes | image |
imageCaption | Text | Yes | image |
background | A select of background classes | Yes | (the block) |
The author sees the image field with an Attributes icon beside it holding the alt text, crop and caption, and the background behind the component's Attributes button. The template reads each by name: