This page is outdated
The information on this page concerns an old or obsolete version of Omeka. If you are using a more recent version, instead see metadata
on Read the Docs.
Description
The show_item_metadata()
helper inserts all the metadata field available for an item in an Omeka archive. It is primary used in the show.php
file in a public theme.
show_item_metadata
has several options available:
Usage
<?php echo show_item_metadata($options = array(), $item = null); ?>
Arguments
- $options (array) - Three options are available:
- show_empty_elements - (bool|string). Setting to false will prevent empty fields from being displayed. Setting to a text string will display empty fields, and display the string entered.
- show_element_sets - An array of element sets (by name) to display.
- return_type - array or html. Defaults to html.
- $item - Item object or null (default). If null, the current item in the loop is used.
Examples
Hide Empty Elements
Set to "true" by default, the show_empty_elements option allows you to limit the fields displayed to all fields or to non-empty fields for an item. Setting this to "false" will only display fields that have data.
<?php echo show_item_metadata(array('show_empty_elements' => false)); ?>
Change the Empty Element String
If you'd like to change the text displayed for empty fields, pass the use the text of the string for the show_empty_elements option. Example:
<?php echo show_item_metadata(array('show_empty_elements' => 'Empty')); ?>
This will display "Empty" instead of "[no text]" in your public theme.
Display Specific Element Sets
If you'd like to display specific element sets, pass the list of sets as an array to the `show_element_sets` option. The following example would display only the Item Type Metadata element set:
<?php echo show_item_metadata( array( 'show_element_sets' => array( 'Item Type Metadata' ) ) ); ?>
Using show_item_metadata for a specific item
If you'd like to use show_item_metadata
to display the metadata of a specific item, you must first use the get_item_by_id helper to get the item object of a specific item. The following example sets the 'show_empty_elements' to false, and displays the metadata for an item with a ID value of '44':
<?php $item = get_item_by_id(44); echo show_item_metadata(array(), $item); ?>