midcom.helper.metadata
- Metadata toolbar in MidCOM Authoring Interface
- Displaying metadata on site with MidCOM 2.6+
- Displaying metadata on site with MidCOM 2.4
MidCOM provides a centralized metadata management and editing system for all content objects. The metadata system is also used for controlling approvals and publication. The metadata editor can be accessed from anywhere in the AIS interface :
Displaying metadata on site with MidCOM 2.6+
MidCOM 2.6 includes a Metadata Service that is responsible for setting meta tags on the site and providing an API for site developers to access metadata.
In MidCOM there are two sets of metadata for most pages:
- node: metadata about the current folder
- view: metadata about the current page (availability depending on component)
The two sets of metadata may be accessed using the get_node_metadata() and get_view_metadata() methods of the metadata service.
For example, to display the author of current page, do the following:
// Get reference to the metadata instance
$metadata =& $_MIDCOM->metadata->get_view_metadata();
// Retrieve the property using the metadata key
$publisher = $metadata->get('publisher');
// Retrieve the corresponding person
$person = new midcom_db_person($publisher);
// Display name
echo $person->name;
In real-world scenarios using the contact display widget would most likely make sense here as it would provide nice, hCard compatible output.
Page classification
In addition, there is the concept of page class, which is a textual classification of current page usually originating from the datamanager schemas. It can be used for things like CSS body classing.
<body class="<?php echo $_MIDCOM->metadata->get_page_class(); ?>">
Displaying metadata on site with MidCOM 2.4
MidCOM 2.4 did not populate meta tags automatically. See Displaying metadata on site with MidCOM 2.4 article for how to do it manually.
