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.

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.