metadata — Get metadata for a record.

View-related functions


The metadata function is the easiest and safest way to include record metadata in HTML output. metadata offers support for Element Text metadata, data stored directly in database columns, and custom metadata properties.

metadata automatically returns output HTML-escaped for inclusion in a page where appropriate. The escaping can be optionally disabled. Values also automatically passed through the Element Display Filter, though this too can be optionall disabled.

metadata($record, $metadata, $options = array())

Get metadata for a record.

  • $record (Omeka_Record_AbstractRecord|string) – The record to get metadata for. If an Omeka_Record_AbstractRecord, that record is used. If a string, that string is used to look up a record in the current view.
  • $metadata (mixed) – The metadata to get. If an array is given, this is Element metadata, identified by array(‘Element Set’, ‘Element’). If a string, the metadata is a record-specific “property.”
  • $options (array) – Options for getting the metadata.




The first parameter can be either a record object or the string name of a record type. The string form is used when accessing “current” records set through set_current_record or loop.


For records that carry Element Set metadata, get the value for an element by passing the element set and element name as an array in the second parameter, e.g. array('Dublin Core', 'Title').

You can also get properties of the record by passing the name of the property as a string in the second parameter. Valid property names differ between record types. Every public property of a record (sometimes called the “columns” of the record because this is the data stored in the columns of the database) is a valid metadata name here. Many records have special additional properties that are available as well:

  • Collection
    • total_items
  • File
    • uri
    • fullsize_uri
    • thumbnail_uri
    • square_thumbnail_uri
    • permalink
    • display_title
  • Item
    • item_type_name
    • collection_name
    • permalink
    • has_files
    • file_count
    • has_thumbnail
    • citation

Since version 2.5, all the Element Set-carrying records (Collection, File and Item) also have the special property display_title that returns a simplified version of their title.

The above list only covers core records. For other records, like those added by plugins, see the plugin’s documentation or the getProperty() method of the record.


Valid keys for the $options array are:

  • all: If true, return an array containing all values for the field.
  • delimiter: Return the entire set of metadata as a string, where entries are separated by the given delimiter.
  • index: Return the metadata entry at the given zero-based index.
  • no_escape: If true, do not escape the resulting values for HTML entities.
  • no_filter: If true, return the set of metadata without running any filters.
  • snippet: Trim the length of each piece of text to the given length in characters.
  • ignore_unknown: If true, do not throw an error if the requested metadata element does not exist. (Since version 2.5)
  • Passing simply the string ‘all’ is equivalent to array('all' => true)
  • Passing simply an integer is equivalent to array('index' => [the integer])


Use the metadata function to get the Element Set metadata for a collection. The snippet option can be used to limit the information to only the first 150 characters.

<div class="collection record">
        $description = metadata($collection, array('Dublin Core', 'Description'), array('snippet' => 150));
    <?php if ($description): ?>
        <p class="collection-description"><?php echo $description; ?></p>
    <?php endif; ?>

When calling the metadata function within a loop, pass in a string of the current record type.

<h1><?php echo metadata('collection', array('Dublin Core', 'Title')); ?></h1>

The metadata function also grabs the record metadata.

<h1><?php echo metadata('simple_pages_page', 'title'); ?></h1>

See Also