Content Types

Contents

Content types are the essential elements of Content Studio and the content API. Structured, indexed and searchable content items are created from Content types. Content types build on the Schema system, so they are very similar to other configurable forms in Enonic XP.

Name

Content types have a unique identifier in the following format <namespace>:<name>

Content types defined by developers will use the app name as namespace, and may for example look something like this: com.example.app:my-content-type

In addition to the custom defined types, several [built-in] content types exits. These use reserved namespaces, as they are not specific to your app.

Content forms

Below is an example content type 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)
  <is-abstract>false</is-abstract>  (5)
  <is-final>true</is-final>  (6)
  <is-built-in>false</is-built-in>   (7)
  <allow-child-content>true</allow-child-content>  (8)
  <allow-child-content-type>base:folder</allow-child-content-type>  (9)
  <allow-child-content-type>${app}:article-*</allow-child-content-type>
  <form> (10)
    <input name="firstname" type="TextLine">
      <label>First Name</label>
    </input>
    <input name="lastname" type="TextLine">
      <label>Last Name</label>
    </input>
  </form>
</content-type>
1 display-name (required) The human readable name of the content type. Optionally specify the i18n attribute to define a mapping to localize the value. The localization key must then be declared and localised in the resource bundle.
2 display-name-label (optional; since v7.1) Enables you to override the default <Display Name> placeholder used in the content form.
3 description (optional) Set a description that is shown when creating the content type.
4 super-type (required) Refers to the root controller of the form. For custom content types this should typically be set to base:structured.
5 is-abstract (optional; default: false) If true, you cannot create content with this content type.
6 is-final (optional; default: false) If true, it is not possible to create new content types that “extend” this.
7 is-built-in (optional; default: false) Only specified by built-in content types.
8 allow-child-content (optional; default: true) If false, no content will be allowed to be created or moved under content of this content type (e.g. prevents child content under media)
9 allow-child-content-type (optional) If specified, only content of content types matching specified criteria will be allowed to be created or moved under content of this content type. The pattern matching used is the same as the one described in MATCH. XP XP 7.7.0 7.7.0
10 form (required) The custom Form definition for your content type.
allow-child-content-type will not have effect if allow-child-content is set to false

Standard content properties

When creating content, regardless of it’s content type, the following properties will always exist. Value type and index options are specified in parentheses.

_id (string)

The content id (this is the same as node id)

_name (string, fulltext, ngram)

The content name (same as node name)

attachment (propertySet)

If content contains attachments, a list of attachments with respective properties will be listed here.

creator (string)

The user principal that created the content.

createdTime (dateTime)

The timestamp when the content was created.

data (propertySet)

Contains properties defined by the contentType schema.

displayName (string, fulltext)

Name used for display purposes.

language (string)

The locale-property of the content.

modifiedTime (dateTime)

Last time the content was modified.

owner (string)

The user principal that owns the content.

page (propertySet)

The page property contains page-specific properties, like template and regions. This will typically be reference to a page-template that supports the content-type.

publish (propertySet)

Contains publish times, e.g publish.from

type (string)

The content schema type.

workflow (propertySet)

(Since v7.1) A property-set containing properties related to the workflow, e.g. the state being READY for publishing or IN PROGRESS

x (propertySet)

A property-set containing properties from x-data and mixins.

Built-in content types

Enonic XP comes with a set of built-in content types that can be used no matter what apps are installed. They are grouped into the following prefixes: Base, media, and portal.

Structured (base:structured)

Abstract base type for creating custom content types. The structured content type is the foundation for basically any other structured content you can come up with - such as the Person content in the example above.

is-abstract

true

is-final

false

allow-child-content

true

Shortcut (base:shortcut)

Used for referencing or redirecting to another content item in the structure. Optional name-value parameters can be set to be added to the redirect URL.

is-abstract

false

is-final

true

allow-child-content

true

Folder (base:folder)

Folders are simply containers for child content, with no other properties than their name and Display Name. They are helpful in organizing your content.

is-abstract

false

is-final

false

allow-child-content

true

Media (base:media)

Abstract type for files uploaded via Content Studio or through the content API. Files are created as "media" content types, aka "media types". All media types inherit the following settings:

is-abstract

true

is-final

false

allow-child-content

false

Text (media:text)

Plain text files such as .txt, and .csv

super-type

base:media

Data (media:data)

Miscellaneous binary file formats.

super-type

base:media

Audio (media:audio)

Audio files.

super-type

base:media

Video (media:video)

Video files.

super-type

base:media

Image (media:image)

Bitmap image files.

super-type

base:media

Vector (media:vector)

Vector graphic files like .svg

super-type

base:media

Archive (media:archive)

File archives like .zip, .tar, and .jar

super-type

base:media

Document (media:document)

Text documents with advanced formatting, like .doc, .odt, and .pdf

super-type

base:media

Spreadsheet (media:spreadsheet)

Spreadsheet files like .xls, .xlsx

super-type

base:media

Presentation (media:presentation)

Presentation files like .key and .ppt

super-type

base:media

Code (media:code)

Files with computer code like .js, .c, .pl, and .java

super-type

base:media

Executable (media:executable)

Application files such as .app, .exe and .jar

super-type

base:media

Unknown (media:unknown)

Files that do not manch any of the above

super-type

base:media

Site (portal:site)

Site content items serves the purpose of acting as website root entries. It enables selecting and configuring applications for a website. Content types, components, filters, x-data and more from the applications selected will be available for use inside the site content tree.

Application-specific content types may only be used within a site, to which the application has been added.
super-type

base:structured

is-abstract

false

is-final

true

allow-child-content

true

Page Template (portal:page-template)

Instead of always having to configure the page controller for each content, page templates provide a default setup for how a content type is displayed on a site.

super-type

base:structured

is-abstract

false

is-final

true

allow-child-content

true

Template folder (portal:template-folder)

This is a special content type. Every site automatically creates a child content of this type named _templates. The templates folder holds all the page templates of that site. It may not hold any other content type, and it may not be created manually in any other location.

super-type

base:folder

is-abstract

false

is-final

true

allow-child-content

portal:page-template

Fragment (portal:fragment)

The Fragment content type represents a reusable page component. A content of this type contains a page component(Part, Layout, Text, Image) that can be re-used in other pages. But it only needs to be maintained in one place.

super-type

base:structured

is-abstract

false

is-final

true

allow-child-content

true

To create a content of type portal:fragment edit an existing page with Page Editor, select the context menu of an existing component in the page, and then clicking on “Create Fragment”. Once created, the fragment content can be referenced in other pages by inserting a Fragment component in the page.

A Fragment content can be edited with Page Editor and the changes applied to the component will immediately be available in the pages that include the fragment. When a page containing fragment a component is rendered, the components of the portal:fragment content pointed by the fragment component are rendered in the place of the fragment component.

There is a default page for rendering and edit fragments. The default page does not have any styles defined, but it is possible to render it with the application theme and styles by defining a controller mapping with <match>type:'portal:fragment'</match>

Unstructured (base:unstructured)

The unstructured content type is a special content type that permits the creation of any property or structure without actually defining it first. It can only be used via API.

This is convenient for storing content, when the properties and their types vary from instance to instance - and the item needs to be editorially managed and published. For most such scenarios, developers should consider using the low-level storage instead.

Since the content data is unstructured (basically schemaless), there is currently no default user interface (i.e. in Content Studio) that facilitates editing of the unstructured content.

is-abstract

false

is-final

true

allow-child-content

true

Custom Content Types

Custom Content Types can be created using simple XML files. They are managed and deployed via applications.

Using XML, each content type must have a separate directory in the application resource structure: /src/main/resources/site/content-types/my-content-type

Each directory must then hold a file where the file name matches the parent directory name, and an .xml extension: my-content-type.xml.

A content type may optionally have its own specific icon. The icon can be assigned to the content type by adding a PNG or SVG file with the same name in the content type directory: my-content-type.svg

Extend any content type

You may dynamically extend both built-in and custom-defined content types through the use of X-data.


Contents

Contents