Content Fields
After creating aΒ Content Type, you can extend it by adding Content Fields to it.Β Content fields have aΒ name
Β and anΒ id
. The name is used as the label above the field in the edit screens. The id is the key that is used as an attribute to call on the object variable in the theme files. In the example of the βColored Buttonβ ContentΒ Type (Element Type), you could add a field for the background color of the button.
In the userβs edit screen for a colored button it would say βBackground color of the buttonβ above the field. In theΒ theme fileΒ (elements/colored_buttons/colored_button.plate
) you would useΒ colored_button.bg_color
Β to call the value of the field on theΒ object. In this case,Β colored_button
Β being the object with the βColored buttonβ Content Type, andΒ bg_color
Β being the field id and attribute name for the colored_button object.
Read the documentation onΒ objectsΒ for more on how to call the attributes inside the theme files.
Content Field kinds
You can add the following kinds of content fields to a content type.
Text Field
A single line text field, that can be used for titles etc.
Text area
A multiline text field, suitable for longer texts. This field can be turned into a code field with syntax highlighting, so the user can type in code. This field is also best used when using theΒ edit_text_inline
Β templating tag.
Media field
A field that gives the user access to the media library, where he can pick or upload new images, PDFβs and other attachments. Calling a media field object attribute returns anΒ attachment object.
Choice field
This field gives the user one or more choices to choose from. You can add possible choices (predefined values), or pick a true/false choice option. The possible choice field kinds are:
Radio button (1 choice)
Checkboxes (Multiple choices, saved as an array)
Dropdown (1 choice)
An on/off switch (true or false)
References field
Read all about references fieldsΒ here.
Link field
The user can choose a post from a dropdown to link to, an attachment from the media library, or just type in a (external) URL.
Array field
The user can add multiple values to a single field, that can be iterated through in the theme files. There are two kinds of values accepted: text values, and media values. The latter being picked from the media library, just like the media field.
Date Time field
The user can choose a date or time from a picker field. The value of this content field is either a date, time or both. The date and date/time can be formatted with theΒ date filterΒ tag from liquid. When only a time is picked, the field returns a string.
Β