CMS Ametys supports different types of content (articles, news, photo galleries, FAQ, ...). The types of content available depend on the extensions (plugins) used.
The most commonly used content types are described in the User Manual.
A content type is a multiple extension point. An integrator can create new content types (seminar, job, etc.) according to your needs.
Icons, glyphs or 16x16, 32x32 and 48x48 pixel icons
A right (optional) to restrict the creation of the type of content to those entitled to it
A set of typed attributes (e.g. title, description, image, files, date, etc.).
Properties (optional)
Des validateurs globaux (optionnel) pour définir des règles de validation entre plusieurs éléments (ex: startDate < endDate)
Views
Each view defines the list of attributes and properties it requires, from among the attributes and properties of the contained type. For example, an "abstract" view will need the title and illustration attributes, while a "main" view will need all attributes.
A content type is an extension point of type org.ametys.cms.contenttype.ContentTypeExtensionPoint. The declaration must comply with the following XML format:
XML content type declaration format
Oops!
Copy to clipboard failed. Open the code and copy it manually.
The glyph (or the "medium" icon if there is no glyph), as well as the label and description, are used for the "Add content" menu.
The glyph is also used when inserting content into a page and in search engine results. (In these 2 cases, if the glyph is not present, the "small" icon is used.
Attributes
Attributes are classic parameters as described on the Parameters general page, with a few variations and additional elements.
SinceAmetys 4.7, two syntaxes have coexisted: - the classic syntax, detailed below, - and the historical syntax, presented in a separate §. It is possible to declare certain attributes with the classic syntax and others with the historical syntax.
Simple declaration
Like any parameter, an attribute has at least a unique name, a label, a description and a type (string, date, long, ...) and is declared as follows in the tag <cms:metadata>:
Example of the declaration of a "Title" string attribute, mandatory
Oops!
Copy to clipboard failed. Open the code and copy it manually.
Instruction <validation> allows you to define validation rules for an attribute:
<mandatory> to make the attribute mandatory
<regexp> to define a regular expression
<invalidText> to personalize the message in the event of incorrect input (regular expression not respected)
<custom-validator> java class implementing the org.ametys.runtime.util.parameter.Validator to define your own validator
For exampleorg.ametys.runtime.util.parameter.TextValidatorfor simple text fields or org.ametys.runtime.plugins.core.util.parameter.RichTextValidator for rich fields, support a
<maxlength> for a maximum supported number of characters
Example of validation for a mandatory "address mail" field
Oops!
Copy to clipboard failed. Open the code and copy it manually.
See further examples on the Parameter overview page, chapter "Validation".
Widget modification
It is possible to specify a "widgetFor example, for an attribute of type "string", you can use "edition.textarea" to modify the attribute on several lines. For example, for an attribute of type "string", you can use widget "edition.textarea" to modify the attribute on several lines. The widget tag is used for this purpose. <widget> as in the example below:
Example of a widget
Oops!
Copy to clipboard failed. Open the code and copy it manually.
Multiple composite attributes can be defined, i.e. they can be repeated as many times as required. For example, to be able to add 0 to n attachments to a content item. These are known as "repeaters".
Example of a repeater declaration
Oops!
Copy to clipboard failed. Open the code and copy it manually.
add-label redefines the tooltip of the add button ("Add entry" by default)
del-label redefine the tooltip of the delete button ("Delete an entry" by default)
header-label allows you to set a custom label for each repeater entry. The value is a phrase that references the repeater's field values using the {field} syntax. Par exemple ici: {amout} € du {date} {sent:pick("", "(envoyée)")}
between the {} you must enter the field identifier, and optionally a function to apply to it, to be chosen from Ext.util.Format Here are a few examples: * {date:date("c")} où "c" est un format de date à choisir dans Ext.Date * {datetime:pick("", " - ")}{datetime} pour préfixer le datetime de " - " si il est non vide * {linkArticle:or("[Aucun]")} pour écrire "[Aucun]" si la valeur est vide * {boolean:pick("Faux", "Vrai")} pour un boolean
Since version 4.8 ofAmetys, it is possible to display repeater entries in a table in the edit form. Please note that this display mode cannot be used for repeaters containing rich-texts or other composite attributes. In this case, table mode will be ignored. We therefore recommend reserving this display mode for simple repeaters, consisting of no more than 4 or 5 attributes.
Example of a repeater declaration in table mode
Oops!
Copy to clipboard failed. Open the code and copy it manually.
On the repeater, add the mode parameter with the table value
On the attributes that make up the repeater, it is possible, but not necessary, to adjust the width of certain attributes.
Either by using the width parameter. By specifying the pixel size of certain attributes. The other attributes will share the remaining space equally.
Either by using the flex. The flex allows you to give proportions between attributes. The default value is 1.
Example: with 2 attributes, if one of the 2 has a value of 0.5 and the other 1. The total is 1.5. The first attribute takes 1/3 of the width, the second the remaining 2/3.
Enumerations
An enumerated attribute can take a value from a defined list: a static or dynamic list.
For content attributes that specify a target content type, the default value can be of type "attribute". This allows you to search for the first content whose attribute has a particular value.
The target attribute cannot be in a composite or in a repeater, and must be of type string, long or double.
Example:
The definition below defines the default French value for the "Language of instruction" attribute (value taken from a reference table).
Oops!
Copy to clipboard failed. Open the code and copy it manually.
the <right> determines the right of the contributor
if the read-write-direction is worth :
write: the contributor can only modify the attribute if he has the "Web_Right_SuperEdit" right; otherwise, he will have read-only access to the attribute.
read: the contributor will have read/write access to the attribute only if he/she has the "Web_Right_SuperEdit" right
Read or read/write restriction based on workflow state
Oops!
Copy to clipboard failed. Open the code and copy it manually.
A property can reference a model element to remote content. In the following example, linked-content is a content attribute of the content type being declared:
Oops!
Copy to clipboard failed. Open the code and copy it manually.
You can also create a more complex property by creating a class java and declaring a property that points to this class. For example, in project spaces, brief objects have a pinned property, which determines whether the brief object is tagged with the 'pin' label:
Oops!
Copy to clipboard failed. Open the code and copy it manually.
The <global-validators> allows you to define validation rules between several attributes. You can define your own global validator by implementing the org.ametys.cms.contentype.ContentValidator. Des validateurs ermettant de vérifier les intervalles entre 2 attributs existent déjà dans Ametys :
org.ametys.cms.contenttype.validation.DateIntervalValidator pour vérifier l'intervalle entre 2 attributs de type date,
org.ametys.cms.contenttype.validation.DateTimeIntervalValidator pour vérifier l'intervalle entre 2 attributs de type datetime,
org.ametys.cms.contenttype.validation.LongIntervalValidator pour vérifier l'intervalle entre 2 attributs de type long,
org.ametys.cms.contenttype.validation.DoubleIntervalValidator pour vérifier l'intervalle entre 2 attributs de type double
A content type can contain several global validators. These validators are used to define validation rules between several attributes. For example, we can check that the value of an attribute of type date is lower than the value of another attribute of type date :
Example of the declaration of a global validator which checks that the value of the "start" attribute (of type datetime) is less than the value of the "end" attribute (also of type datetime).
Oops!
Copy to clipboard failed. Open the code and copy it manually.
A view is a set of model elements. Each view refers to the declared elements required to display it.
SinceAmetys 4.4, two view syntaxes have coexisted: - the classic syntax, detailed below, - and the historical syntax, presented in a separate §. It is possible to declare some views with the classic syntax and others with the historical syntax.
ForAmetys versions prior to 4.4, only historical syntax is available.
Properties can only be referenced by views that use the new syntax.
Some views have a type attribute, set to "view" or "edition". SinceAmetys 4.6.0, this type is no longer used, and the attribute can be removed without any problem.
Syntax
A view is declared as follows, in the <view> :
Example of "main" view
Oops!
Copy to clipboard failed. Open the code and copy it manually.
The name is the view name (ex: main, abstract, link, details, ...) For more details on view names, see "Mandatory and optional views" below.
The internalThis optional feature allows you to "privatize" the view, i.e. make it invisible to the contributor.
The group is used to group the various elements of the view.
The name corresponds to the group name. This attribute is optional, but may be necessary when you want to override views (see corresponding §).
The role attribute defines the grouping type:
La valeur tab represents a grouping by tabs
The value fieldset corresponds to a border representing the grouping
This attribute is optional: if not defined, it takes the default value tab for the first grouping level, and the value fieldset for lower levels.
The label defines the group label
The description defines the group description
Item tags refer to a model element described in the content type, indicating its name. This may be an attribute, a property defined by the content type, or a system property.
Pour les version 4.4 à 4.7 inclues, la syntaxe est <attribute-ref name="title" />, et non <item ref="title" />
the label defines the view label. If left blank, the view name will be used as the label.
the description defines the view description
the icons tag is used to define view icons
small, medium and large tags, to define 16x16, 32x32 and 48x48 pixel icons respectively
the glyph tag for the pictogram. If the pictogram is not specified, but there is a medium icon, this will be used.
decorator tag to add a decorator to the pictogram
Include one view in another
Syntax available from version 4.8 ofAmetys
You can include a view in another view using the following syntax:
Oops!
Copy to clipboard failed. Open the code and copy it manually.
As part of inheritance, or when modifying a content type (see corresponding § below), it is possible to override a view, for example to add an attribute, without redefining the view completely. To do this, simply add the override attribute, with the value true, when defining the view.
Modifying general view data
In the example below, the view's "privatization", label, description and icons are modified. These elements are not mandatory. If they are not filled in when a view is modified, the information in the overloaded view is taken into account.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
In the example below, the "subject" attribute is added before the "title" attribute. If the "title" attribute is not present in the view, the "subject" attribute is added at the end of the view.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
In the example below, the "subject" attribute is added after the "title" attribute. If the "title" attribute is not present in the view, the "subject" attribute is added at the end of the view.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
In the example below, the "subject" attribute is added at the end of the "presentation/general" group. If the "presentation/general" group is not present in the view, the "subject" attribute is added at the end of the view. To override a view that has groups, it is important that all the groups in this view are correctly named.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
In the example below, the "subject" attribute is added after the "title" attribute, which is in the "presentation/general" group. If the "presentation/general" group is not present in the view, the "subject" attribute is added at the root of the view, after the "title" attribute if there is a reference to the "title" attribute at the root of the view, or at the end of the view. If the "title" attribute is not present in the "presentation/general" group, the "subject" attribute is added at the end of the "presentation/general" group.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
In the example below, the "title" attribute at the view root is removed from the view. If the "title" attribute is not present in the view root, no element is deleted.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
In the example below, the "title" attribute in the "presentation/general" group is removed from the view. If the "title" attribute is not present in the "presentation/general" group, no element is deleted.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
In the example below, the "alt-text" attribute in the "illustration" composite is removed from the view. If the "illustration/alt-text" attribute is not present in the view, no element is deleted.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
It is not possible to add an attribute to a composite or repeater.
Mandatory and optional views
You can define as many views as you like. However, some views are mandatory and must be declared for all types of content:
the "main" view (mandatory) used to render content in its "full" view
the "default-edition" view (optional) used for content modification. If this view is not present, the "main" view will be used for content modification.
the "abstract" view (optional) used to render content in its "summary" view (in a content upload, for example)
the "link" view (optional) used to render content in its "link" view
the "details" view (mandatory) to define the attributes to be displayed in the "Content properties" tool
the "index" view (optional) is used by the front-end search engine, to define saxed attributes in the case of page search services (old search engine), or the new page search engine.
To be rendered, a view is linked to a file XSL. The input data XML for this XSL file corresponds to the attributes declared in this view.
Historical syntax
In this old syntax, a view is declared as follows, in the tag <metadata-set> :
Example of "main" view
Oops!
Copy to clipboard failed. Open the code and copy it manually.
The name is the view name (e.g.: main, abstract, link, details, ...). For more details on view names, see "Mandatory and optional views" above.
The internalThis optional feature allows you to "privatize" the view, i.e. make it invisible to the contributor.
The fieldset defines the attribute grouping
The role attribute defines the type of grouping:
The value tab represents a tabbed grouping
The value fieldset corresponds to a border representing the grouping
This attribute is optional: if not defined, it takes the default value tab for the first grouping level, and the value fieldset for lower levels.
The label defines the group label
The description defines the group description
Beacons metadata-ref refer to an attribute described in the content type, indicating its name (it is not possible to reference a property in a view with the new syntax)
The label defines the view label
The description defines the view description
With historical syntax, it is not possible to create joined views.
Tags
Content types can be tagged.
Tags enable specific processing at Java.
There are 3 tags recognized by all Ametys applications:
private: a private content type is one that cannot be created and does not appear in search engines by default.
reference-table: the content type is a reference table (see below).
mixin: content type that is semantically a role (see below)
The declaration of "tags" in the content type is written as :
Oops!
Copy to clipboard failed. Open the code and copy it manually.
To avoid having to completely redefine the "main" view, the instruction <include from-supertype=".."> can be used to include all attributes of the inherited view.
Depuis la version 4.8, il est possible de référencer une autre vue que la vue courante avec <include from-supertype=".." view=".."/>.
If, on the other hand, you want to insert the new attribute in a specific place on the modification form, you'll need to redefine the view.
Since version 4.6, views can be overloaded without being completely redefined. See § Content type overloading.
To inherit multiple content types, the inherited content types must be separated by commas.
Specific types of content
The roles
Roles are transversal content types that complement the semantics of a content type.
It is possible to create content from a role.
For example:
The Dateable role lets you add dates to a content type
The Locatable role adds an address to a content type
News inherits Article and adds the Dateable role
Event inherits News and adds the Locatable role
A search of all Dateable content will return both News and Events.
Technically, a "role" is very similar to a content type:
it is declared in the same way by specifying the "mixin" tag (see the chapter on tags above)
it is used with content type inheritance
they can also be added dynamically via the GUI
If we take the example of geolocated events above, we can imagine another way of doing things using a :
definition of the "content-type.Localisable" role
Oops!
Copy to clipboard failed. Open the code and copy it manually.
Reference tables are content types that can be used with dedicated editing and search tools.
Allowed attribute types are limited to simple attributes: a reference table cannot contain composites or repeaters.
This type of reference table can only be modified in a table.
A reference table is declared by specifying the "reference-table" tag (see the chapter on tags above).
If you want reference table values to appear in the search engine, you need to add a property to their title. (see the Indexing and Searching chapter below)
Private content type
A private content type is one that cannot be created using the standard tools ("Add content" menu or when creating a page) and that does not appear in search engines by default.
Content types ODF (training, courses, elp, ...) are private content types. They have their own search and creation tools. They cannot be searched using the standard search tool.
A private type is declared by specifying the "private" tag (see the section on tags above).
Abstract content type
A content type can be declared "abstract" with the attribute abstract="true"
Oops!
Copy to clipboard failed. Open the code and copy it manually.
l'identifiant réel interne du type de contenu est "content-type.<id_du_content_type>"
the resources/img directory contains resources (notably the 16x16 and 32x32 pixel icons of the content type)
the default catalog i18n is that of the application (in WEB-INF/i18n)
le répertoire stylesheets/content-type.<id_du_content_type> contient l'ensemble des fichiers content-type.<id_du_content_type>.xsl et content-type.<id_du_content_type>-<nom_de_la_vue>.xsl pour le rendu graphique des différentes vues
The [plugin_name] directory can correspond to any existing plugins name. We recommend using "web".
Example of file organization for the declaration of a new "seminar" content type
Definition in a plugin
In plugin, a new content type is defined in an extension in the file plugin.xml:
Oops!
Copy to clipboard failed. Open the code and copy it manually.
It is possible to override an existing content type. For example, to add attributes and/or global validators, or to override views. As with the declaration of a new content type, modifications can be defined in 2 places:
in the WEB-INF/param/content-types/_override directory
in a new plugin to eventually set up more advanced treatments.
Modification of the WEB-INF/param/content-types/_override directory
To override a content type, you can create a <id du content type>.xml in the WEB-INF/param/content-types/_override of your application
Example of overloading "News" and "Multimedia gallery" content
Example of overloading in the _override folder: addition of the "subject" attribute, redefinition of the "link" view and overloading of the "main" view.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
In plugin, modifications to a content type are defined in an extension in the file plugin.xml. It is possible to modify several content types at once.
The modification of a content type can be conditional. For example, you can use the org.ametys.cms.contenttype.ConfigBasedContentTypeOverrides class to make changes only if a configuration parameter is specified, or if its value is true (in the case of a Boolean parameter). You can also create your own conditions, by creating a java class in your plugin, which implements the org.ametys.cms.contenttype.ContentTypeOverridesExtension interface.
The org.ametys.cms.contenttype.StaticContentTypeOverrides class allows unconditional modifications.
Example of overloading in a plugin : Article and News types, unconditional
Oops!
Copy to clipboard failed. Open the code and copy it manually.
So there are several places to create or modify a content type and its elements. Here is the order in which the various element declarations will be taken into account:
First, we look at the elements defined by the content type's parents (using the same algo as above).
Then we look at the elements defined or modified in the initial declaration of the type
Then we look at the modifications made by the overloads in the extensions. Note that overloads in extensions are done in random order. We don't know in advance whether a given extension will be taken into account before any other extension.
And finally in the WEB-INF/param/content-types directory
Overloading views is more complex, because in each of the above cases, it's possible to completely redefine a view, or just overload a few elements. We start by finding out at which level (initial declaration, overload by extension or WEB-INF/param/content-types directory) the last complete (re)definition of the view is located. Then look for overloads in equivalent levels or below.
Examples of content type declarations
The examples below provide an overview of the syntax for declaring a content type. The algorithm for modifying the elements of a content type is also described.
Complete example of a simple content type declaration
Here's a complete example of how to declare a new content type, part of the News type:
Oops!
Copy to clipboard failed. Open the code and copy it manually.
The 2 extensions will be loaded in random order, so the order of the attributes in the view may change. For example, in the main view of the example above, the 2 added attributes are added after the same "document-subtitle" attribute. The first extension loaded will put its attribute after "document-subtitle", the second extension between "document-subtitle" and the attribute added by the first extension.
Redefinition of the abstract view in the _override folder :
Oops!
Copy to clipboard failed. Open the code and copy it manually.
We redefine the abstract view in the _override folder, i.e. at the last modification level. The abstract view will therefore contain only the "title" and "abstract" attributes.
Indexing and searching
All model elements (attributes and properties), as well as all system properties, are indexed in Solr. They can therefore be used as search columns.
Fulltext system property
This property contains all content test data. It therefore contains all data that can be converted to text format, with the exception of content data.
To add the title of linked content to the fulltext of current content, you can add a property in the content type to point to the title of the linked content.
Example:
Oops!
Copy to clipboard failed. Open the code and copy it manually.