<< Content objects  Permissions >> 

Content datatypes

This document will give an introduction and overview of content datatypes. All examples uses the datatype ezstring as reference.

The datatype has three responsibilites, two which are required and one which is optional. They are class attribute definition, object attribute editing and object attribute viewing.

Class attribute definition

This is optional and may implement an UI for setting default data or defining the validation for an object attribute. The class must then implement the functions storeClassAttribute, validateClassAttributeHTTPInput, fixupClassAttributeHTTPInput, fetchClassAttributeHTTPInput, which deals with input validation from HTTP and storing of data in the database.

Uses the template design/standard/templates/class/datatype/edit/ezstring.tpl for UI.

Object attribute editing

Defines the validation of object attribute input using HTTP as well as storing of data in the database. The class must then implement the functions validateObjectAttributeHTTPInput, fixupObjectAttributeHTTPInput, fetchObjectAttributeHTTPInput, initializeObjectAttribute.

Uses the template design/standard/templates/content/datatype/edit/ezstring.tpl for UI.

Object attribute viewing

The viewing does not require any functions in the class but only requires the template which defines the look of the attribute.

Uses the template design/standard/templates/content/datatype/view/ezstring.tpl for UI.

Required PHP file

Each datatype consists of at least one php file which defines it's behaviour. It can also have several other files to handle storage but that's up to each datatype.

kernel/classes/datatypes/ezstring/ezstringtype.php [ Class ]

The main datatype handler, contains the code for reading various input, validating and storing.

Required templates

design/standard/templates/content/datatype/view/ezstring.tpl

The template used for viewing an attribute in a content object. The template variable $attribute is passed to the template which will contain an eZContentObjectAttribute object.

design/standard/templates/content/datatype/edit/ezstring.tpl

The template used for editing an attribute in a content object. The template variable $attribute is passed to the template which will contain an eZContentObjectAttribute object.

design/standard/templates/class/datatype/edit/ezstring.tpl

The template used for editing an attribute in a content class. Here default parameters and other constraints may be setup for content objects. The template variable $class_attribute is passed to the template which will contain an eZContentClassAttribute object.

Other related files

The following files are related to a given datatype, this includes classes, templates and other files.

kernel/classes/ezdatatype.php [ Class ]

The base class for all datatypes which they must inherit from and implement a couple of functions for it to work properly. See the API reference documentation for more information.

kernel/classes/ezcontentclass.php [ Class ]

The main class which is used for defining classes in the system.

kernel/classes/ezcontentclassattribute.php [ Class ]

The class which defines an attribute which is connected to an eZContentClass.

kernel/classes/ezcontentobject.php [ Class ]

The class which defines the instantion of an eZContentClass.

kernel/classes/ezcontentobjectattribute.php [ Class ]

The class which defines an attribute which is connected to an eZContentObject.

kernel/classes/ezpersistentobject.php [ Class ]

The base class which all database related classes inherit from. It defines functions for fetching, storing and removing data in a database using a definition structure.

lib/ezutils/classes/ezhttptool.php [ Class ]

The utility class used for fetching HTTP post variables.

lib/ezutils/classes/ezinputvalidator.php [ Class ]

The main class which handles text input validation and correction. The datatype must return a validation state which is defined in that class for the input validation to work properly.

design/standard/templates/class/edit.tpl

The template which specifies the whole content class editing view. It should not be necessary to to change this to achieve a given datatype.

design/standard/templates/content/edit.tpl

The template which specifies the whole content object editing view. It should not be necessary to to change this to achieve a given datatype.

design/standard/templates/content/view/full.tpl

One of the viewmodes for a content class.

settings/site.ini

The key AvailableDataTypes in group DataTypeSettings defines which datatypes are available in the UI, add the datatype string id of your datatype if you want it to appear amongst the other datatypes.


Exponential