Skip to the content
Documentation

Class attributes

No ratings yet

A class attribute is one field of a content class: the Title of an article, the Image of a gallery item, the e-mail address of a user. Each attribute has a datatype, which decides what it can hold, and a set of properties that apply to every object of the class.

Properties of every attribute

Property Meaning
Name The label editors see in the edit form; translatable.
Identifier The name used in templates and code ($node.data_map.title) and in name patterns (<title>).
Datatype What the attribute holds and how it is edited and shown. Chosen when the attribute is added and fixed after that. See Datatypes.
Required The object cannot be published while the attribute is empty.
Searchable The attribute's text goes into the search index.
Information collector The attribute is filled in by visitors, not editors: a form field. See Information collection.
Disable translation When ticked, the attribute has one value for all translations (useful for a price or a product number); it is edited in the main language only.
Category Groups attributes in the edit form, for example Content and Meta (content.ini [ClassAttributeSettings] CategoryList[]).
Placement The order of the attributes in the edit form and in the data map.

Most datatypes add their own properties: a default value, a maximum length, the allowed classes of a relation, the options of a selection, the maximum file size of an image.

Attributes and objects

For every attribute of its class, each version of each object stores one object attribute per language (the table ezcontentobject_attribute). Templates read them through the object's data map:

{def $map = $node.data_map}
{if $map.image.has_content}
    {attribute_view_gui attribute=$map.image image_class='medium'}
{/if}
{$map.title.content|wash}
{undef $map}

has_content asks the datatype whether the attribute holds a value; attribute_view_gui shows it with the datatype's view template (content/datatype/view/<datatype>.tpl in the design).

Translations of dates and numbers

How a date or a number is written depends on the locale of the siteaccess (site.ini [RegionalSettings] Locale), not on the attribute. Template operators such as l10n format them: {$map.publish_date.content.timestamp|l10n( 'shortdate' )}.

Contributors

Comments (1 historical)

Written by readers of the earlier documentation sites, kept as they were.

  1. Translation of dates, numerals and other...

    Piotrek Karaś ·

    It was suggested that translating dates, numerical values, prices, email addresses, etc. doesn't make much sense.
    I would say that it entirely depends on what's the pertinent purpose of an attribute, and it has to be carefully decided during the planning stage. There seems neither a technical, nor any other reason why dates, numerical values or other types should not change with language context. An attribute with translatable or untranslatable e-mail address simply stands two different attributes, and both can have their specific uses.

Comments

Add a comment

Comments are read by a moderator before they appear.