Created
November 1, 2012 15:07
-
-
Save jeremyboggs/3994185 to your computer and use it in GitHub Desktop.
Switch certain field headings in Omeka's custom_show_item_metadata function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function custom_show_item_metadata(array $options = array(), $item = null) | |
{ | |
$item = $item ? $item : get_current_item(); | |
if ($dcFieldsList = get_theme_option('display_dublin_core_fields')) { | |
$otherElementSets = array(); | |
$elementSets = get_db()->getTable('ElementSet')->findForItems(); | |
foreach ($elementSets as $set) { | |
if ($set->name == 'Dublin Core') continue; | |
$otherElementSets[] = $set->name; | |
} | |
$html = '<h2>' . __('Dublin Core') . '</h2>'; | |
$dcFields = explode(',', $dcFieldsList); | |
foreach ($dcFields as $field) { | |
$field = trim($field); | |
// Create $fieldLabel, change its value for certain fields. | |
switch($field) { | |
// Check if $field is 'Description' | |
case 'Description': | |
$fieldLabel = 'Header'; // Change value to 'Header' | |
break; | |
// Check if $field is 'Relation' | |
case 'Relation': | |
$fieldLabel = 'Further Reading'; // Change value to 'Further Reading' | |
break; | |
// Check if $field is 'Text' | |
case 'Text': | |
$fieldLabel = 'Further Reading'; | |
break; | |
// Leave the default for headings you don't want to change. | |
default: | |
$fieldLabel = $field; | |
} | |
if (element_exists('Dublin Core', $field)) { | |
if ($fieldValues = item('Dublin Core', $field, 'all')) { | |
// Use $fieldLabel for heading | |
$html .= '<h3>'.__($fieldLabel).'</h3>'; | |
foreach ($fieldValues as $key => $fieldValue) { | |
if (!item_field_uses_html('Dublin Core', $field, $key)) { | |
$fieldValue = nls2p($fieldValue); | |
} | |
$html .= $fieldValue; | |
} | |
} | |
} | |
} | |
$html .= show_item_metadata(array('show_element_sets' => $otherElementSets)); | |
return $html; | |
} else { | |
return show_item_metadata($options, $item); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment