Content Fields

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.

Β