I need to update my theme/items/show.php to allow the display of some special cases.
For that I am manually looping through the related files:
$itemFiles = $item->Files;
foreach($itemFiles as $itemFile) {
// do all kinds of stuff
}
In this loop I need to display the Title of the File itself. When I try to output metadata('file', array('Dublin Core', 'Title), $itemFile);
I get an error because 'file'
has not been set.
Initially I thought it might be as simple as echo metadata($itemFile, array('Dublin Core', 'Title'));
, but that does not work.
Apparently in Omeka 1.x you could get the same result like this: https://omeka.org/codex/Display_Specific_Metadata_for_an_Item_File.
How can I achieve the same thing in Omeka 2.0?
(It's probably right in front of me :)
Ok, so metadata($itemFile, array('Dublin Core', 'Title'));
is exactly how you do it.
It helps though if you edit the title of the correct record *blush*.
Do you happen to know how to do that when you have multiple field values and want to display them all?
The examples of using delimiter see to all be from the older versions of Omeka, and I haven't gotten beyond this:
<?php echo metadata('item', array('Dublin Core','Title')); ?>
In figuring out something to work for my question I realized that my question didn't have anything to do with your question. (I didn't know that at the time.) Sorry for posting on your topic.
<?php echo metadata('item', array('Dublin Core','Title'), array('delimiter'=>', ')); ?>
In general the options for metadata()
are in the Omeka developer documentation.
If you're doing a simple character-separated list, then delimiter
is the easiest way to go, but you can also use the all
option, which gives you back an array that you can handle in whatever way you choose.
I haven't found an example of how to use the all
option yet (though please show me one if you are up for it). I had actually used the delimiter
like this to adjust the items/show.php (cheating due to ignorance):
<div class="element-text"><?php echo metadata('item', array('Dublin Core','Title'), array('delimiter'=>'</div><div class="element-text">')); ?></div>
My goal is to recreate record-metadata.php to display particular fields. The idea is to have as much info in the basic Dublin Core fields as available (so that it's all there when harvested and searched), but to be more selective to avoid TMI on the public display.
When you use the all
option you just get back an array:
$titles = metadata('item', array('Dublin Core', 'Title'), array('all' => true));
Then you can loop through $titles
and display them with whatever markup you want:
foreach ($titles as $title):
echo '<div class="element-text">';
echo $title;
echo '</div>';
endforeach;
Thank you for the help with this example. I used your example code to have links to the resource listed above the rest of the metadata. (So the links are listed twice, once at the top of the page just above and image of the resource and once in line with the rest of the metadata below the image. The idea was to have the links consistently above the fold.)
It turned out that it was way easier to use your Hide Elements plugin to limit the metadata displayed on items/show than to adjust record-metadata.php and add it to the theme files. So Yay! and thanks for that plugin too.