Functions/link to item

link_to_item()

This function links to various items in the collection, such as thumbnail images, metadata elements, site Title.

From the Omeka root directory, this function is defined in the following file:

  • application/helpers/LinkFunctions.php

Required Arguments:

  • string HTML for the text of the link.

Optional Arguments:

  • array Attributes for the <a> tag.
  • string The action to link to ('show' by default). Leave this as the default value unless you know what you're doing.
  • Item An Item record can be passed in order to link to an item without using loop_items(). Also do not use unless you know what you're doing.

Example

For example, this will display links to 10 recently added items. The text of each link will be the Dublin Core Description for the item, and each link will have the 'recent-item' class.

<?php set_items_for_loop(recent_items(10)); ?>
<?php if (has_items_for_loop()): ?>

<ul class="items-list">
<?php while (loop_items()): ?>

<li class="item">
<?php echo link_to_item(
    item('Dublin Core', 'Description'), // Display the description
    array('class'=>'recent-item')); ?> // Give it a class for styling
</li>

<?php endwhile; ?>
</ul>

<?php endif; ?>