Displaying metadata on site with MidCOM 2.4
MidCOM provides a centralized metadata management and editing system for all content objects. This article concerns on how to display the metadata with MidCOM version 2.4. For newer versions of MidCOM, refer to the main article.
If you're using MidCOM template, it is easy to display the MidCOM metadata on the website.
Simply include the following code in your style before the <(head-extra)> element is called.
if ( is_object($GLOBALS['midcom'])
&& $_MIDGARD['self'] == $GLOBALS['midcom_site']['uri'])
{
$nap = new midcom_helper_nav();
$current_leaf = $nap->get_current_leaf();
if ($current_leaf)
{
$current_object = $nap->get_leaf($current_leaf);
}
else
{
$current_object = $nap->get_node($nap->get_current_node());
}
if ($current_object[MIDCOM_NAV_OBJECT]->parameter('midcom.helper.metadata', 'keywords'))
{
$midcom_site["metadata"]["keywords"] = $current_object[MIDCOM_NAV_OBJECT]->parameter('midcom.helper.metadata', 'keywords');
}
if ($current_object[MIDCOM_NAV_OBJECT]->parameter('midcom.helper.metadata', 'description'))
{
$midcom_site["metadata"]["description"] = $current_object[MIDCOM_NAV_OBJECT]->parameter('midcom.helper.metadata', 'description');
}
}
