exhibits related to item

Hi,

I used to have my own function in Omeka 1.5 that will help me to access the exhibits title for a certain item. For example, if I am in the item.php under exhibits, I used to display the title of all the related exhibits where the item is used. This is the way I made my function and I wonder if there is functionality or a better way with Omeka 2. Thanks in advance

I have this function in custom.php in my theme.

function mlibrary_link_to_related_exhibits($item) {
require_once "Exhibit.php";
$db = get_db();

$select = "
SELECT e.* FROM {$db->prefix}exhibits e
INNER JOIN {$db->prefix}sections s ON s.exhibit_id = e.id
INNER JOIN {$db->prefix}section_pages sp on sp.section_id = s.id
INNER JOIN {$db->prefix}items_section_pages isp ON isp.page_id = sp.id
WHERE isp.item_id = ? group by e.id";

$exhibits = $db->getTable("Exhibit")->fetchObjects($select,array($item));

if(!empty($exhibits)) {
echo '<div class="element"><h2>Related Exhibits</h2>';
echo '

    ';
    foreach($exhibits as $exhibit) {
    echo '
  • '.exhibit_builder_link_to_exhibit($exhibit).'
  • ';
    }
    echo '
</div>';
}
}

If you are using Exhibit Builder 2.x, that code should probably still work. If you're using 3.x, the table names have changed a bit. See:

http://omeka.org/forums/topic/linking-to-exhibit-from-item-page-1