Skip to content

Instantly share code, notes, and snippets.

@jeremyboggs
Created November 6, 2012 14:22
Show Gist options
  • Save jeremyboggs/4024999 to your computer and use it in GitHub Desktop.
Save jeremyboggs/4024999 to your computer and use it in GitHub Desktop.
Custom show_item_metadata function for Omeka that loops through an internal array of labels and their associated fields.
<?php
/**
* Show Item Metadata function that loops through an internal array of labels
* and their associated fields.
*
* @param Item|null $item
* @return string The HTML for the item metadata.
*/
function berlin_show_item_metadata($item = null)
{
$html = '';
$item = $item ? $item : get_current_item();
// The list of fields we want to display, using 'Label' => item() Put them
// in the order you want them displayed. Add more to the array, separated
// by a comma.
$fields = array(
'Header' => item('Dublin Core', 'Description', null, $item),
'Primary Source' => item('Item Type Metadata', 'Text', null, $item),
'Further Reading' => item('Dublin Core', 'Relation', null, $item)
);
// Loop through our array of fields, breaking out the label and value.
foreach ($fields as $label => $value) {
// Only display the field if it has a value.
if ($value) {
// Construct the HTML for displaying the label and value.
$html .= '<div class="field field-'. text_to_id($label) .'">'
. '<h2>'.$label.'</h2>'
. '<div class="field-value">'
. $value
. '</div>'
. '</div>';
}
}
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment