Node classes
Smereka – invisible objects of Smereka. Their primary purpose – to serve as an interface to the database. An instance of the class can read their attributes from the database and write modified attributes to the database. Therefore, new node classes declared when the new entity appears in the information model, which contain new set of attributes.
It should be noted that Smereka have some terminological confusion between node classes and PHP classes. PHP classes – a programming objects that created in the memory of server based on information from the database. Smereka provide polymorphic constructor of PHP classes; what PHP class it will create is defined by class attribute of node and corresponding metaclass.
For various node classes one PHP class can be instantiated. A new node class will be declared in order to create a new entity with its unique set of attributes; new PHP class will be declared, when the new entity should have some new, specific methods of processing. If standard Node PHP class methods are enough for the certain purpose, than introduction of a new PHP class is redundant.
Therefore, within documentation the word "class" mostly means the node class, not PHP class.
Class does not determine the appearance of web pages. There are page templates, which are responsible for attributes usage to compile HTML code.
Metaobjects
Smereka determine the properties of their objects through their other items (metaobjects). Their properties are set directly in the Smereka source code, and other object declarations (metaobjects instances) are created and edited using a standard Smereka node editor.
To work with metaobjects editor one must have administrative rights, then go to the "User settings" page and click on the link "metadata".
Smereka has four metaobjects: metaclass, metatemplate, metaeditor and metafield (metaattribute).
Metaclass
Metaclass a special node class, which describes the properties of other node classes. It has the following attributes:
Module – path to the PHP module, which contains the source code of class; it must be the relative path, calculated from the Smereka root folder. Typically – node.php.
ClassName – PHP class name for instantiation. Typically – Node.
Hidden – switch which must be set to hide class in pick lists. Node editor will be not able to change current node class to this hidden class during editing. Typically used for administrative classes (groups, users, etc.).
Fields – list of attributes of the class, separated by commas. For example, Node class looks like this: symbname, class, Template, accesslevel, link, Hidden, HideChildren, Smerecasheable, Indexable. It contain not all attributes of class, but only those for which the editor template has to create controls. Field names must match the symbname of some Metaattribute node. If the field name prefixed with the "-" (minus) symbol, this field will be removed from the editor template.
link – in the metaclass context used as link to the superclass. If it is set, current metaclass becomes a subclass of linked metaclass and inherits all its fields. Editor template exposes own attributes of metaclass first, then group fields, inherited from superclasses. If some of the superclasses attributes is redundant for subclass, its name should be "subtracted" in the Fields attribute.
ClassTpl – class template; is is a link to metatemplate, which is used by this metaclass. Smereka can use class template in soft and hard contexts. In the soft (default) context class template will be applied only when the node (an instance of the class) does not have attribute "template". In the hard context node attribute "template" (even if it is specified) is ignored and class template always apply instead. An example of the hard context is RSSChannel class, which is always used in combination with a RSSMaker template. Its use with a different pattern may be inappropriate.
Description – a textual description of the class. Read these descriptions – the best way to understand the purpose of the class.
Metatemplate and metaeditor
These metaobjects determine the appearance of web pages generates by Smereka. Metatemplate determines the appearance of the page for the reader; metaeditor determines the appearance of the page for editing the respective nodes; the remaining properties are the same:
Description – textual template description. Read those descriptions – the best way to understand the purpose of the template.
TemplateText – template HTML text code. This code may contain smeretags (lookup field), and sections. This text is stored in the database. This method of storage is recommended, but Smereka can use templates from separate files.
link – in the metatemplate context used as link to the template-ancestor. If it is set, the template must contain not a full code, but sections, which should been replaces in the ancestor template.
Module – path to the PHP module, which contains the source code of PHP class for template. it must be the relative path, calculated from the Smereka root folder. Typically – page.php.
ClassName – PHP class name for instantiation. Typically – Page.
Hidden – switch which must be set to hide the template in the pick lists. Node editor will be not able to change current node template to this hidden template during editing. Typically used for class templates.
Path – If TemplateText leaved blank, Smereka will search the template file at this relative path, which is calculated from the Smereka root folder. For example: ../example/templates
FileName – template file name. For example: newtpl.html. While using this method of storing templates be aware that Smereka will search for ../example/templates/en/newtpl.html, where en – name the current language. So, even if the site contains only one language version, you still need to create intermediate directory named by this language.
Metaattribute
Metaattribute is the attribute definition. Please be aware that one attribute can be used with different classes and even carry different meaning in the context of different classes. It has the following attributes:
DataType – data type attribute.
ControlType – type of HTML control element for attribute. Editor template generates the appropriate item based on this attribute. Most of the type of controls clearly dictated by the data types, but for the attribute of "integer" type, for example, you can create a dropdown list or checkbox instead of string field.
Properties – text box with a list of properties in the name="value" style, separated by spaces. For a fixed dropdown list (ControlType = select) you can write a list of items here.
If metaattribute defines the pointer (so its data type is "node id"), one can additionally set in this field node class, that allowed to be a value of the attribute.
For example, Template metaattribute have property Class="33". So, only instance of this class (metatemplate) can be the value of this attribute. Smereka deny all attemptions to set value of this field to the node of another class (including NULL value).
By default this property is not set, so nodes of any class (or NULL) is applicable as value of the field.
LangAware – switch which determines whether the attribute language-aware.
Label – the field label in the editor.
Description – text description of the attribute. Read those descriptions – the best way to understand the purpose of attributes.
Changing of the node class
When the editor change class of an existing node to the new class, Smereka acting on conservative algorithm: all the attributes of the old class already setted will stay attached to the node, even if the definition of a new class does not provide them. Fundamentally, each node can have any attributes (another thing, will they be used somewhere).
Smereka can not determine whether a specific attribute of the node used or not. So, multiple changing of the node class may have the result of the formation of a "tail" of irrelevant attributes. Preferably this situation be avoided.
Please be aware that the Smereka node editor shows not all attributes attached to node and are stored in the database, but only those provided for the current node class and the editor template (template may hide some of the attributes in order to simplify the editor layout).