Object Attributes and Relations
This feature was started in Tiki5 and will be more & more used in Tiki6
Attributes should be used to create cross-feature functionality.
Attributes
To implement transversal features such as geolocalization of objects in tiki, Object Attributes were introduced. Not unlike user preferences, they are key-value pairs stored in the database and are associated to the type and itemId (same as object permissions).
To avoid the inconsistencies seen in the preference naming conventions, the attribute library enforces a few conventions.
- Attribute names may only contain lowercase letters and dots.
- Two levels of scoping are required. First level for bundled attributes must be tiki. Custom extensions can use an other prefix. Second level must be some sort of package name. The rest is up to the implementor.
Valid attributes would be tiki.geo.lat or tiki.geo.lon
Library code is located in lib/attributes/attributelib.php. The library allows to:
- Get all attributes for an object as a map using get_attributes().
- Set a single attribute on an object using set_attribute().
Because all values are fetched at once, the length of the content must remain small. The limit of the size of attribute and relation names is 25 characters.
Current attribute usage in the tiki.* namespace
Please document namespace use here as you start using new attributes in Tiki features
| Attribute | Usage | |
| tiki.geo.lat | Latitude coordinate of the object | |
| tiki.geo.lon | Longitude coordinate of the object | |
| tiki.geo.google.zoom | Zoom level of an object used in Google Maps | |
| tiki.relation.target | Label to be used when referring to the target of a relation | |
| tiki.relation.source | Label to be used when referring to the source of a relation | |
| tiki.article.* | Custom attribute fields for articles | Not appropriate! Attributes should be applicable to all object types |
Relations
The Object Relations allow to qualify a relationship between any two objects in the system or with external resources (URLs). Just like attributes, the qualified name of the relationship must be scoped.
Relations are managed with lib/attributes/relationlib.php.
Because all values are fetched at once, the length of the content must remain small. The limit of the size of attribute and relation names is 25 characters.
Current relation usage in the tiki.* namespace
Please document any relations used in Tiki features here
| Relation | Usage | |
| tiki.article.attribute | Relationship between an article type and it's related custom attribute fields | |
| tiki.file.attach | Attaches File Gallery files to objects (tracker items so far?) | |
| tiki.general.related | Any generic relationship not specific to any feature/module | |
| tiki.link.$type | Links wiki pages ($types are probably semantic etc) | |
| tiki.sheet.$type | Relates sheets and trackers | |
| tiki.user.favorite | Links users to favourite objects (wiki pages only so far?) | |
| tiki.user.banned | To ban users from objedcts (groups initially for 8.x could be extended) | |
Displaying links to relations using the object_link smarty tag
A smarty tag like this will show a link to the object that is at the target end of the relation. The text of the link will be the "tiki.relation.target" attribute set for that relation (i.e. the attribute for an object of type 'relation' and relationId, if any. If there is no such attribute set for that relation, then it will show the usual link as per the normal behavior of the object_link tag.
{object_link type=relation_target id=x}

Last Comments