From The Smartest Wiki
Jump to: navigation, search

Models are user-created informational structures that allow the storage of data with almost any shape. Models are created by the user or developer specifying that certain items on their website are likely to have the same set of attributes every time they appear, even if the values of those attributes are different from item to item. These attributes are known as item properties, and their values as item property values.

There are two kinds of property: some properties of items are built in, and common to every item regardless of which model it belongs to, such as name, ID, and language; other properties are chosen by the user and are different from model to model. User-created properties have two values - a draft value that is edited, and which is updated every time the item is saved, and a 'live' property that is used in production, but only updated when an item is 'published.'

Consistency and default properties

The nature of the flexibility that models provide is that the data they contain can be structured very differently from model to model. Yet when it is websites that are being built, users often frequently look for the same types of information about almost all items listed on a website: Title, description, date, and thumbnail image. Users often also expect the order of items to make sense. To meet these demands, Smartest allows a property to be selected from those that have been added to fulfil the roles of description, date, and thumbnail image, as well as the default sort property and direction. These preferences allow items to be displayed easily and sensibly without always needing their properties to be named in the same way.

Technological underpinnings

Models are stored in the database table ItemClasses and accessed via the SmartestDataObject subclass SmartestModel. Items are stored in the table Items. User-created properties are stored in the table ItemProperties and the values in ItemPropertyValues. A PHP class file is generated for each model, complete with get/set methods, offsets for accessing data in templates, and other internal structures that optimise the function of the items system. These files are stored in System/Cache/ObjectModel/Models/.