Thursday 29 October 2009 2:15:00 am
At Contactivity, we found that the default content class attribute names (image, file, etc) are sometimes confusing to work with: especially in templates where the output of several content classes are combined. It is not always clear what type of datatype we are dealing with (eh, was this a textblock or an xml block?), so we need to go back to the content class definitions to check that. We found that using more descriptive content class attribute names saves us time and makes our code more readable. Our naming convention for eZ publish content class attributes is as follows:
[class_prefix]_[attribute_name]_[datatype_initials]
For example, the attribute identifier for an article is:
art_intro_xmlb
The attribute identifier for a downloadable file in a blog post is:
blp_file_file
Available datatype initials include:
o auth - Authors;
o chkb - Checkbox;
o datt - Date/Time;
o mail - Email;
o file - File;
o imag - Image;
o keys - Keywords;
o mtrx - Matrix;
o link - URL;
o user - User account;
o xmlb - XML block. o etc...
But:
- Some of the attribute names we do not change (for example, the 'image' attribute in the image class) because these are 'ez publish' configuration defaults;
- Of course, the use of more advanced debug info also helps; - Sometimes we need the attribute name of the attributes of two different classes to be the same, in order to simplify a fetch. We have developed a set of standard content class definitions and matching templates that we use as our 'base' design. We are interested to know if anybody else uses naming conventions for content classes. Is there another way to do this?
Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.
|