Content Types

Contents

Content Types

Content Types are the essential elements of Content Studio and the content API.

Form definition

<content-type>
  <display-name i18n="cty.person.displayname">Person</display-name> (1)
  <display-name-label i18n="cty.person.displayname.label">Full Name</display-name-label>(2)
  <description>Create a new person</description> (3)
  <super-type>base:structured</super-type> (4)
  <form>
    <input name="firstname" type="TextLine">
      <label>First Name</label>
    </input>
    <input name="lastname" type="TextLine">
      <label>Last Name</label>
    </input>
  </form>
</content-type>
display-name-label was first introduced in v7.1
1 display-name is the human readable name of the content type. Optionally specify the i18n attribute to define a mapping to localize the value. The localisation key must be then declared and localised in the resource bundle.
2 display-name-label enables you to override the default <Display Name> placeholder used in the content form
3 description - Set a description that is shown when creating the content type.
4 super-type refers to the root controller of the form.

Display name expressions

It’s possible to auto-generate display name based on values from form fields by using ES6 template literals. In the example below, display name will be combination of values from firstName and lastName fields.

Only simple input types may be used as variables, i.e. htmlArea is not supported.
<content-type>
  <display-name>Person</display-name> (1)
  <display-name-expression>>${firstName} ${lastName}</display-name-expression>>
  <form>
    <input name="firstname" type="TextLine">
      <label>First Name</label>
    </input>
    <input name="lastname" type="TextLine">
      <label>Last Name</label>
    </input>
  </form>
</content-type>

Expanding content types

You can use a mixin or X-data to dynamically inject additional form fields inside existing content types.

Contents