Equivalent of metadata function?

Hopefully that’s the right title.

How do we access an item’s individual elements/properties in Omeka-S? For instance, to modify what metadata is included in the browse/search results, or on the item detail page, to customize which metadata elements are displayed and in which order?

Looked through the documentation, but didn’t find anything useful. I did pull this code from browse.phtml (in the default theme). But it’s not clear why “siteSetting” function would be used to pull individual metadata elements.

$headingTerm = $this->siteSetting('browse_heading_property_term', 'dcterms:title');
$bodyTerm = $this->siteSetting('browse_body_property_term', 'dcterms:description');
foreach ($items as $item):
    $heading = $item->value($headingTerm, ['default' => $this->translate('[Untitled]')]);
    $body = $item->value($bodyTerm);
    <li class="item resource">
        <?php echo $item->linkRaw($this->thumbnail($item, 'medium')); ?>
        <h4><?php echo $item->link($heading); ?></h4>
        <?php if ($body): ?>
        <div class="description"><?php echo $body; ?></div>
        <?php endif; ?>
<?php endforeach; ?>

The call that’s doing the work there is $item->value(), and the parameter it takes is the “term” you want to get the value of (e.g., dcterms:title).

The siteSetting stuff is just there because the site allows you to configure which property will be used (if, say, you have items that are best browsed by seeing properties other than dcterms:title and dcterms:description).

Ah ok… so to confirm, like this?



That’s the equivalent of metadata for S.

Thanks John! I am continuing to look through the documentation but not finding this piece of info.


If that is correct, can I contribute a doc page to either:

  • Key concepts - $item
  • Themes - customizing item pages

… or similar, per your suggestion.

Yeah, there seems to be an issue there… the general problem is that the new docs are somewhat based on the structure of the old ones, where most things were in functions or view helper classes. In Omeka S, several important pieces of functionality are really only available directly on the “representation” objects (item, item set, etc.). metadata('item', array('Dublin Core', 'Title')) vs $item->value('dcterms:title') being a good example of a typically difference from Classic to S.

You’re absolutely right that this is a hole in the S developer documentation. As for the form an improvement would take… we may have to think on that a little. Perhaps a page or section just laying out how to display metadata (both one at a time and all at once) would be the way to go.

1 Like

I just had to locate and reference this again, after poking around in the documentation. Since I don’t use Omeka functions in PHP regularly, I will always need a reference. It would be great to add a page to documentation either under Theming or elsewhere that explains all of the possible uses of $item object.

You’re completely right (still), this is a pretty major and basic thing we absolutely need to have coverage for in the developer documentation.

How does this look as a start? It should appear automatically on the actual documentation soon, once it rebuilds.

It’s available on the actual documentation now.


My next comment is that “Using Representations” is a very broad term, maybe developer specific given the document title. But the “Displaying Metadata Values” section is the key title - maybe it could be replicated or virtually duplicated in the Themes area?

Yes, structure is very up in the air and we have a tricky time not wanting to really duplicate (as much for issues keeping things in sync if there are changes as for any other reason)… and the representations come up if you’re using the API internally, in controllers, as well as in themes.

One easy option just to start could be to just link directly to that section/heading from theme-specific documentation.

1 Like