Datamanager2 Schemas
From OpenPSA Wiki
Datamanager2 Schemas were introduced with Datamanager 2 during the MidCOM 2.5 series. They primarily serve as an configuration layer for the Datamanager-based handling of MidCOM DBA objects. In spite of the similar-sounding name, they are not related to the MgdSchema XML files, which are used to describe the database table layout.
Most MidCOM Components are based on Schemas, and there data structure as well as validation and other rules can be altered by user-defined Schemas. The default schema is usually located in config/schemadb_default.inc.
Aside from specifying the data type, field name and storage location, Schemas are the place where widgets are assigned to content, and input validation can be triggered.
[edit] Creating custom Schemas
Schemas are regular PHP arrays and can be defined Sitegroup wide in the Snippetdir sitegroup-config:
- Create a Snippetdir named like the Component in question (e.g. net.nehmer.blog)
- Create a Snippet named
configwith at least the following lines:
"schemadb" => "/sitegroup-config/componentname/schema", "schemadbs" => Array ( "/sitegroup-config/componentname/schema" => "Our schemadb", ), "default_schema" => "default",
- The actual Schemas are then defined in the Snippet
schema
For a specific Topic, Schemas can be defined as well. This is usually set in a MidCOM Toolbar
Schema fields have the following main properties:
[edit] Storage
This was called "Location" in Datamanager1 and is used to tell the system where to store the contents of the field. These can be the fields the object has in the Midgard MySQL Database. In addition to regular Midgard fields, two other possibilities exist:
- parameter - store the content to a Parameter of the object
- attachment - store the content to a file Attachment of the object
Furthermore, it is possible to specify null as the storage location, which means that no automatic storage will happen or tmp, which will save contents in a tempoaray object.
