Linking to exhibit from item page

I'm looking for a simple way to link back to an exhibit from the item page. Does the solution offered in this thread still work?

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

Looks like it still should

I've added Jeremy's function to my custom.php file and am getting the following error:

Zend_Controller_Router_Exception
slug is not specified
#0 /application/libraries/Zend/Controller/Router/Rewrite.php(470): Zend_Controller_Router_Route->assemble(Array, false, true)
#1 /application/libraries/Zend/View/Helper/Url.php(49): Zend_Controller_Router_Rewrite->assemble(Array, 'exhibitSimple', false, true)
#2 /application/helpers/Url.php(79): Zend_View_Helper_Url->url(Array, 'exhibitSimple', false, true)
#3 /application/helpers/UrlFunctions.php(53): Omeka_View_Helper_Url->url(Array, 'exhibitSimple', Array, false, true)
#4 [internal function]: uri(Array, 'exhibitSimple')
#5 /application/helpers/UrlFunctions.php(186): call_user_func_array('uri', Array)
#6 /plugins/ExhibitBuilder/helpers/ExhibitFunctions.php(75): public_uri(Array, 'exhibitSimple')
#7 /plugins/ExhibitBuilder/helpers/ExhibitFunctions.php(50): exhibit_builder_exhibit_uri(NULL, NULL, NULL)
#8 /plugins/ExhibitBuilder/helpers/ExhibitFunctions.php(720): exhibit_builder_link_to_exhibit(NULL, Object(Exhibit), Array, NULL, NULL)
#9 /themes/berensons/custom.php(553): link_to_exhibit(Object(Exhibit))
#10 /themes/berensons/items/show.php(175): link_to_related_exhibits(2927)
#11 /application/libraries/Omeka/View.php(113): include('/home/bbdigita/...')
#12 /application/libraries/Zend/View/Abstract.php(888): Omeka_View->_run('/home/bbdigita/...')
#13 /application/libraries/Zend/Controller/Action/Helper/ViewRenderer.php(900): Zend_View_Abstract->render('items/show.php')
#14 /application/libraries/Zend/Controller/Action/Helper/ViewRenderer.php(921): Zend_Controller_Action_Helper_ViewRenderer->renderScript('items/show.php', NULL)
#15 /application/libraries/Zend/Controller/Action/Helper/ViewRenderer.php(960): Zend_Controller_Action_Helper_ViewRenderer->render()
#16 /application/libraries/Zend/Controller/Action/HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#17 /application/libraries/Zend/Controller/Action.php(527): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#18 /application/libraries/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('showAction')
#19 /application/libraries/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#20 /application/libraries/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#21 /application/libraries/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#22 /application/libraries/Omeka/Core.php(165): Zend_Application->run()
#23 /index.php(28): Omeka_Core->run()
#24 {main}

Ah. Sorry. I guess there was a change that I hadn't seen before.

This should work

function link_to_related_exhibits($item) {

    $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 = ?";

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

    if(!empty($exhibits)) {
        echo '<h3>Related Exhibits</h3>';
        echo '<ul>';
        foreach($exhibits as $exhibit) {
            echo '<li>'.link_to_exhibit(null, array(), null, null, $exhibit).'</li>';
        }
        echo '</ul>';
    }
}

OK, the error has gone away, but the link isn't appearing on my show pages. Ex:

http://bbdigital.org/berenson/items/show/2927

It should appear just below the item metadata. I'm sure I'm missing something simple here...

BTW, the Europeana Omeka sites have something similar configured in precisely the way we're looking to set this up with a "Back to Exhibition" link to the section page.

http://exhibitions.europeana.eu/exhibits/show/art-nouveau-en/mastercrafts/item/56

Here's my attempt at an updated version. I wasn't able to get link_to_exhibit to work in the custom function. I think the problem is that I couldn't figure out how to set the exhibit id. So instead, I am using the following. If you can help me use link_to_exhibit instead, that would be greatly appreciated.

function link_to_related_exhibits($item) {

    $db = get_db();

    $select = "
    SELECT e.* FROM {$db->prefix}exhibits e
    INNER JOIN {$db->prefix}exhibit_pages ep on ep.exhibit_id = e.id
    INNER JOIN {$db->prefix}exhibit_page_entries epe ON epe.page_id = ep.id
    WHERE epe.item_id = ?";

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

    if(!empty($exhibits)) {
        echo '<h3>Related Exhibits</h3>';
        foreach($exhibits as $exhibit) {
            echo '<p><a href="/exhibits/show/'.$exhibit->slug.'">'.$exhibit->title.'</a></p>';
        }
    }
}

Updated for Exhibit Builder 3.0:

function link_to_related_exhibits($item) {

    $db = get_db();

    $select = "
    SELECT e.* FROM {$db->prefix}exhibits AS e
    INNER JOIN {$db->prefix}exhibit_pages AS ep on ep.exhibit_id = e.id
    INNER JOIN {$db->prefix}exhibit_page_blocks AS epb ON epb.page_id = ep.id
    INNER JOIN {$db->prefix}exhibit_block_attachments AS epba ON epba.block_id = epb.id
    WHERE epba.item_id = ?";

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

    if(!empty($exhibits)) {
        echo '<h3>Appears in Exhibits</h3>';
        foreach($exhibits as $exhibit) {
            echo '<p>slug.'">'.$exhibit->title.'</p>';
        }
    }
}

Thanks!