Modelling content

Modelling content

A content type is the shape of one kind of entry: a blog post, a product, the site footer. You build one in barakoBrew under Content types, then New content type. This page covers that form as barakoBrew 1.10.0 draws it, and the parts of a type you cannot change once it exists.

Creating a type

Fill in these, in order:

  • Display name. What editors see, such as "Blog post".
  • API name (slug). Filled in from the display name (lower case, letters, digits and hyphens) until you edit it yourself. It is what the API and the public URL use, so pick it on purpose.
  • Description. Optional.
  • Serve this type publicly. Off by default. On, anyone can read published entries without signing in at /api/public/<api name>. Fields marked sensitive stay hidden either way. You can turn it on or off later from the type's page.
  • One entry only. For a value the site has exactly one of, such as its address or footer text. The type is edited on one screen instead of a list and a second entry is refused. This cannot be changed later.
  • Path on the site. Where an entry lives, such as /blog/{slug}, with {slug} once. The feed and the sitemap build links from it. Leave it empty to use the server's setting. You can change this later.

Create content type stays disabled until the type has a display name, an API name and at least one field.

Adding fields

Each field has a display name, an API field name and a type. The types are grouped as barakoBrew offers them:

Group Types
Text Text, Long text, Rich text, Markdown, Slug, UUID, Token
Numbers Whole number, Decimal number, Money
Time Date, Date & time, Time
True or false Yes / No
Structured List, Nested object, JSON, Location
Files and images File, Inline image (kept in the entry, up to 64 KB)
Checked on write Email, URL, Reference, Choice

A Token is generated by the server and never edited, so it has no Required switch. The form asks for more only where the type needs it: choice and reference fields can hold several values, a reference names the content type it points at, a money field has a currency and decimal places, and a token has a length.

Every field also carries:

  • Required.
  • Section, Editor and Role, which decide where and how the entry form draws it.
  • Sensitivity: Public, Members, Sensitive or Hidden. Members is offered only against an API that speaks contract 9 or later (barakoCMS 5.1.0). For Sensitive and Hidden you can name the roles that may read the field, and pick a mask: the default, remove the field, redact to ***, or show the last four characters.

Save or cancel an open field before you create the type. An open field holds edits the type does not have yet, and barakoBrew says so under the form.

Lifecycle

By default an entry is Draft, Published or Archived. The lifecycle section lets a type define its own states, the state new entries start in, and named transitions between them. The API reads a lifecycle only when the type is created, so it is set on this screen and cannot be changed afterwards.

What cannot be changed afterwards

The API has no update or delete for a type's fields. To change the shape of a type, create a new type and move the entries across. barakoBrew puts this above the New content type form and again on the type's page.

After creation you can still change:

  • public delivery
  • the path on the site
  • uniqueness rules
  • how each field is edited
  • the options of a choice field
  • the currency of a money field

Event sourcing

An event-sourced type treats its change history as the record, and the current version is derived from it. The setting is eventSourced on POST /api/content-types. It defaults to false, and it is permanent in both directions: it cannot be turned on later and it cannot be turned off.

barakoBrew 1.10.0 has no control for it. The New content type form does not send eventSourced, so a type made there is not event sourced. To make an event-sourced type, create it through the API before its first entry. An event-sourced type refuses fields that are anything other than Public. Once it exists, barakoBrew lists and edits it like any other type. See Event-sourced content types in the barakoCMS docs before you choose it.