Content model¶
Content model overview¶
The content structure in Ibexa DXP is based on content items. A content item represents a single piece of content: an article, a blog post, an image, a product, etc. Each content item is an instance of a content type.
Tip
An introduction to the content model for non-developer users is available in Ibexa DXP user documentation.
Content items¶
A content item consists of:
- Content information
- Fields, defined by the content type. The Fields can cover data ranging from single variables and text lines to media files or blocks of formatted text.
Content information¶
General information about a content item is stored in a ContentInfo
object.
ContentInfo
does not include Fields. It contains following information:
id
- the unique ID of the Content object. These numbers are not recycled, so if an item is deleted, its ID will not be reused when a new one is created.
contentTypeId
- the unique numerical ID of the content type, on which the content item is based.
name
- the name is generated automatically based on a pattern specified in the content type definition.
The name is in the main language of the content item.
Note
name
is always searchable, even if the Field(s) used to generate it are not.
sectionId
- the unique number of the Section to which the content item belongs.
New content items are placed in the Standard Section by default.
This behavior can be changed, but content must always belong to some Section.
See Sections for more information.
currentVersionNo
- current version number is the number of the published version or of a newly created draft (which is 1).
published
- true if a published version exists, otherwise false.
ownerId
- ID of the User who initially created the content item.
It is set by the system the first time the content item is published.
The ownership of an item cannot be modified and will not change even if the owner is removed from the system.
modificationDate
- date and time when the content item was last modified.
This is set by the system and cannot be modified manually, but will change every time the item is published again.
publishedDate
- date and time when the content item was published for the first time.
This is set by the system and cannot be modified.
alwaysAvailable
- indicates if the content item is shown in the main language when it's not present in another requested language.
It is set per content type.
remoteId
- a global unique ID of the content item.
Accepts up to 100 characters. Cannot contain non-printable characters and control sequences (anything in ASCII range \x00
- \x1F
).
It's recommended to either let this value be generated by the Public PHP API as an MD5 hash, or at least to generate it as a hash (e.g. one from SHA family).
mainLanguageCode
- the main language code of the content item.
If the alwaysAvailable
flag is set to true, the content item is shown in this language when the requested language does not exist.
mainLocationId
- identifier of the content item's main Location.
status
- status of the content item. It can have three statuses: 0 – draft, 1 – published and 2 – archived.
When an item is created, its status is set to draft. After publishing the status changes to published.
When a published content item is moved to Trash, the item becomes archived.
If a published item is removed from the Trash (or removed without being put in the Trash first), it is permanently deleted.
The Fields of a content item are defined by the content type to which the content item belongs. s
Fields¶
A Field is the smallest unit of storage in the content model and the building block of all content items. Every Field belongs to a Field Type.
Beyond the built-in set of Field Types, you can create your own.
Field value validation¶
The values entered in a Field may undergo validation, which means the system makes sure that they are correct for the chosen Field Type and can be used without a problem.
Validation depends on the settings of a particular Field Type. It cannot be turned off for a Field if its Field Type supports it.
Field details¶
Aside from the Field Type, the Field definition in a content type provides the following information:
Name – a user-friendly name that describes the Field. This name is used in the interface, but not internally by the system. It can consist of letters, digits, spaces and special characters; the maximum length is 255 characters. If no name is provided, a unique one is automatically generated.
Identifier – an identifier for internal use in configuration files, templates, PHP code, etc. It can only contain lowercase letters, digits and underscores; the maximum length is 50 characters. This identifier is also used in name patterns for the content type.
Description – a detailed description of the Field.
Required – a flag which indicates if the Field is required for the system to accept the content item. By default, if a Field is flagged as Required, a user will not be able to publish a content item without filling in this Field.
Note
You can use the ContentService::validate()
method to decide whether the required Fields or whole content items are checked for
completeness at other stages of the editing process.
The Required flag is in no way related to Field validation. A Field's value is validated whether the Field is set as required or not.
Searchable – a flag which indicates if the value of the Field will be indexed for searching.
The Searchable flag is not available for some Fields, because some Field Types do not allow searching through their values.
Translatable – a flag which indicates if the value of the Field can be translated. This is independent of the Field Type, which means that even Fields such as "Float" or "Image" can be set as translatable.
Depending on the Field Type, there may also be other, specific information to fill in. For example, the "Country" Field Type allows you to select the default country, as well as to allow selecting multiple countries at the same time.
Tip
You can disable the possibility to edit specific Field details per Field Type by adding custom service definition for ModifyFieldDefinitionsCollectionTypeExtension
.
Content versions¶
Each content item can have multiple versions. Each version has one of the following statuses: draft, archived or published.
A new version is created every time a content item is edited. The previous published version is not modified.
Only one version can be published at the same time. When you publish a new version, the previous published version changes its status to Archived.
The number of preserved archived versions is set in ibexa.repositories.default.options.default_version_archive_limit
.
By default it is set to 5.
A new version is also created when a new language is added to the content item.
Products¶
Products are a special type of content that holds products you can manage in the built-in PIM system.
See PIM for more information.