Skip to content

Attribute Types for Contents

Matteo Emanuele M. edited this page May 30, 2013 · 6 revisions

Attribute types for Content Models

Attributes available to create Content Types in the Entando platform

Table of Contents

Introduction

This guide will describe the Attributes Types available to create Contents Types from scratch

Target Audience

The reading is recommended to anyone who is designing / organizing the Contents for a new portal and is preparing to create the Content Types.

Prerequisites

This guide assumes that the reader has already read The Entando Model and Content Types mini-howto

top

Attributes Types

The study of the organization of the information and of the content is an important part in the development of a web portal and it is important to understand that a website works if its contents are well arranged.

Organizing contents in Entando means putting together the types of information needed to build the structure of Content Types, as shown in Content Types mini-howto.

The Attributes Types for Contents represent the “atomic” information; putting them together structures the information in the portal.

Content Types can be easily created from the administration interface; however, older versions (< 2.2) of Entando required the XML defining a Content Type to be loaded in the system database.

For the purpose of the current guide we focus on the XML as found in the database; today they are generated when the administrator create new Content Types from the administration interface.

The XML configuration is contained in the table sysconfig of the Port database, in the item contenttypes.

top

Common properties

The configuration of each Attribute Type requires the explicit attributes that determine its properties.

The common attributes are:

name

required

searcheable

indexingtype

The basic syntax of an attribute declaration is the following:

<attribute name="" required="" searcheable="" indexingtype=""> 

Name:

It's the name of the attribute, is used to identify the information.

The name must always start with the first letter capitalized and can not contain spaces and special characters. Its length must be less than 10 characters.

Name is mandatory and its value is arbitrary: look at the example below:

<attribute name="Title"..........  

<attribute name="Author"..........

Required:

Make the attribute mandatory so that its value must be provided.

It Is used for the attributes relevant to the content, without which the Type of Content would not make sense.

It is used to prevents users from submitting incomplete or partial contents.

It has two values: true o false. When not specified, required defaults to false.

The content editor, to make the title and the date mandatory in a content of type News, must declare them required as in the following example:

<!-- mandatory attribute -->
<attribute name="Title" attributetype="Text" required="true" /> 
<!-- optional attribute: it can be left blank --> 
<attribute name="Author" attributetype="Monotext" /> 
<!-- mandatory attribute --> 
<attribute name="Date" attributetype="Date" required="true" /> 

Searchable:

When searchable is true the attribute can be used to sort or to filter content in lists.

This property allows you to add filters based on that Attribute Type when publishing lists of Content, or to be used within the tag wp:contentList.

The creation of the filters has a meaning only when the value of information can be ordered. For example in the following snippet is makes sense to order bye date and Title:

<attribute name="Title" attributetype="Text" searcheable="true" ...
<attribute name="Date" attributetype="Date" searcheable="true" ...
<attribute name="photo" attributetype="Image" ...

Indexingtype:

It declares whether the information should be indexed by search engine.

The attributes indexed by the search engine will be used as search keys to find contents; possible values are text or unstored. The default is unstored, meaning that the attribute is not indexed.

Please note that other values depend on the actual implementation of the indexing engine. Currently only text indexing is supported.

Title and Date are made indexable so that the search engine can search or sort contents by the value of attributes:

<attribute name="Title" attributetype="Text" indixingtype="text" ... 
<attribute name="Date" attributetype="Date" indixingtype="text" ... 
<attribute name="Photo" attributetype="Image" ... 

Title and Date will be indexed, Photo will be excluded from indexing.

Roles:

A Role is a tag of the attribute that allows a predefined use within the application functionality.

For example the administrator can create a Content Type with several Text attributes, each with a different name, but only the attribute with the role jacms:title will be used as the title of the web page if the CEO option was enabled for that page.

<roles> 
  <role>jacms:title</role> 
</roles> 

The roles of attributes are not to be confused with system Roles: the latter is a collection of permission to associate to an Entando user.

Cross-Validation Attributes :

The cross validation is useful when an attribute must be validated against another attribute: it can be used only with numeric attributes such as Date and Number attributes.

The administrator has the option to check by range (rangestart, rangeend) or by exact match (value).

  <attribute name="DateStart" attributetype="Date" searcheable="true" /> 
  <attribute name="DateEnd" attributetype="Date" searcheable="true"> 
    <validations> 
      <rangestart attribute="DateStart" /> 
    </validations> 
  </attribute> 

In the example above we find a real-life cross-validation example: the attribute DateEnd must be greater than DateStart .

OGNL-validation:

OGNL-validation lets users create simple to complex validation checks: the OGNL expression must return a boolean value [ true | false ].

When building the validation expressions the 'root' object identifies the attribute itself (the methods of the attribute can be accessed either implicitly or using the '#attribute' prefix.

The map of the languages supported, '#langs', and the entity the attribute is associated with, '#entity', are immediately available; in addition to these, the parent of a Composite attribute is accessed with '#parent' while the position of the attribute in a list is obtained with '#index'.

The administrator can also specify different messages to help or to report errors or, alternatively, choose a key of the system label to use.

  <attribute name="StartDate" attributetype="Date" searcheable="true"> 
  <validations> 
    <required>true</required> 
    <expression evalOnValuedAttribute="true"> 
      <ognlexpression>&lt;![CDATA[#attribute.date.after(new java.util.Date())]]&gt;</ognlexpression>
      <errormessage>&lt;![CDATA[The start date has to be after than today]]&gt;</errormessage>
      <helpmessage>&lt;![CDATA[The start date has to be after than today]]&gt;</helpmessage>
    </expression> 
  </validations> 
  </attribute> 

In the example above the validation is performed against a date, which must be greater than the current date.

top

Simple attributes types

Attach

It represents the information carried by a file, which is attached to the content.

It consists in a URL corresponding to the desired file and a text that which can either indicate the description or the title.

During the editing, you can select an attachment already present in the Resources or enter a new one.

<attribute name="Attach" attributetype="Attach" />

Boolean

This attribute represents a boolean value which can be either true or false.

This attribute is rendered as two radio buttons labeled with 'yes' or 'no'.

<attribute name="Important" attributetype="Boolean" /> 
<attribute name="RecurringEvent" attributetype="Boolean" /> 

Checkbox

This attribute behaves in the same way as boolean does -actually is an alternative of the Boolean attribute- but is rendered with a checkbox in the administration interface;

<attribute name="Important" attributetype="Checkbox" /> 
<attribute name="RecurringEvent" attributetype="Checkbox" /> 

Date

This attribute represents a date, tracks time within a content; it's often used to filter contents in list by publication date etc.

<attribute name="EventDate" attributetype="Date" searcheable="true" /> 
<attribute name="EndPublicationDate" attributetype="Date" searcheable="true" />

Enumerator

The enumerator attribute represents a textual information which has a predefined set of choices; it is rendered in the form of a select field in the Content edit page.

It supports two additional optional attributes:

separator:

it declares the character to use to separate the arguments of the enumerator. By default the comma “,” is used.

extractorBean:

this attributes represents the name of the Spring bean to use to process the values of the enumerator. The name must exactly match the id of the bean as defined in the Spring configuration file.

A real life example would be the following, with an enumerator containing a list of nations:

<attribute name="Country" attributetype="Enumerator"> 
  <![CDATA[Italy,France,Germany,U.K.,Switzerland,Belgium,Netherland]]> 
</attribute> 

This is the simplest form of an enumerator; the next uses a minus “-” as separator

<attribute name="Country" separator="-" attributetype="Enumerator"> 
  <![CDATA[Italy-France-Germany-U.K.-Switzerland-Belgium-Netherland]]> 
</attribute> 

In the following example the name of the Spring bean which will handle the nations list, “MyExtractorBean” is explicitly declared:

<attribute name="Country" extractorBean="MyExtractorBean" attributetype="Enumerator"> 
  <![CDATA[Italy,France,Germany,U.K.,Switzerland,Belgium,Netherland]]> 
</attribute> 

Again, the name must exactly match the the id of the bean as defined in the Spring configuration file.

Hypertext

This attributes holds an text which can contain HTML tags.

Even if this attribute can contain all HTML tags, we strongly recommend to use only tags which provide meaning and avoiding those which decorate or add graphics.

Hypertext attributes are rendered as textarea in the content edit page; if the FCKEditor is active then the administrator can easily insert external links, links to page to other contents with an apposite toolbar.

  <attribute name="CompleteDescription" attributetype="Hypertext" /> 

Image

This attribute binds an image resource to the content.

The image to provide is always taken from the Image Archive: it is possible to upload new images without interrupting the content edit procedure.

The editor will need to specify the description accompanying the image.

Usually the attributes of type Image are not indexed and are not used to filter contents.

<attribute name="Pic" attributetype="Image" /> 

Link

This attribute represents a hypertext link; it is normally used to include a link in your content: it is possible to define up to three types of links:

  1. external links: a link which point to a location external to the Entando portal
  2. link to page: a link which points to a page of the portal
  3. link to a content: a link to another content
<attribute name="companyEmail" attributetype="Link" /> 
<attribute name="Homepage" attributetype="Link" /> 

Longtext

This attribute represents a simple test; it supports several languages and it is normally used for small descriptions or text longer than a title.

It supports maxLength, minLength and regexp. These are shared with the Text attribute, which behaves in the same way, and are discussed later on.

<attribute name="Abstract" attributetype="Longtext" /> 

Monotext

Monotext represents the information in textual form, but it supports only a language; it is used for all those fields which do not require localization.

Again, this supports maxLength, minLength and regexp .

<attribute name="CompanyName" attributetype="Monotext" /> 

Number

This attributes holds a number; it retains a single value for all the languages.

<attribute name="PracticeNumber" attributetype="Number" required="true" /> 
<attribute name="UserCode" attributetype="Number" /> 
<attribute name="MilesNumber" attributetype="Number" /> 

Text

This attribute holds a simple generic text and and supports several languages.

<attribute name="Title" attributetype="Text" /> 
<attribute name="EventPlace" attributetype="Text" /> 

In addition to the common required, indexingtype and searcheable, a number of properties are supported by all the text-like attributes:

  1. Minimum Length : it expresses the minimum length that the text must have, expressed in characters.

  2. Maximum length: it expresses the maximum length of the text,in characters.

  3. Regular expression validator: the text inserted will be checked against the given regular expression; note how the regular expression is contained on a child tag on its own.

<attribute name="Abstract" attributetype="Text" minLength="10" maxLength="100" />
<attribute name="eMail" attributetype="Text" > 
  <regexp><![CDATA[[.+@\w.*]]></regexp> 
</attribute> 

ThreeState

Similar conceptually to the Boolean attribute, this attributes allows a third status “unspecified” (or “none”) to be present.

<attribute name="PetAllowed" attributetype="ThreeState" required="true" /> 

top

Composed attribute types

All the attributes of the previous chapter could only retain a single type of information, but sometimes it is desirable to aggregate different types of attributes into one attribute: this is where composed attributes come into play.

From a functional point of view it would be perfectly legal to build a content type specifying all the attributes back to back: the content would be formally complete, but from a logical point of view the attributes would appear mutually unrelated and, worse, the relationship between them would not be explicit.

Entando offers three types of composed attributes: List, Monolist, Monolist Composite

List

This Attribute Type represents a set of independent and homogeneous elementary Attributes, each associated with one of the languages defined system.

An immediate consequence is that this kind of list can handle only mono-language basic attributes.

You can declare the number of elements composing the list. After the basic element that composes the list has been chosen, it will be possible to decide, on content basis, how many items will be present in each list associated to the supported languages.

List are represented in XML through the rag <list>: this tag supports the properties name, required and attributetype (“list”); indexingtype and searchable are not available.

This tag supports the new property nestedtype which specifies the basic attribute of the items in the list.

<list name="attach" attributetype="List" nestedtype="Monotext" /> 

Monolist

This attributes is a list that is common to all the system languages; this kind of list handles multi-language and mono-language attributes.

The corresponding tag supports the same properties of the list tag.

<list name="Documents" attributetype="Monolist" nestedtype="Attach" /> 
<list name="Links" attributetype="Monolist" nestedtype="Link" /> 

Monolist composite

This attribute is an aggregate of different simple attributes. It differs form the other list attributes because it has a child tag for every item of the composite.

The base syntax is shown below:

<list name="" attributetype="Monolist" nestedtype="Composite"> 
  <attribute name="" attributetype="" required="" indexingtype="" /> 
  [...] 
 <attribute /> 
</list> 

A real word example would be a content type which models the profile of a person:

<list name="Padre" attributetype="Monolist" nestedtype="Composite"> 
    <attribute name="Name" attributetype="Monotext" required="true" /> 
    <attribute name="Age" attributetype="Number" required="true" /> 
</list> 

It is worth noting that the attributes Name and Age so that the system will consider the attribute valid only when both of them are specified by users.

top

Clone this wiki locally