Creating exhibit themes

Hi,

I'm not quite sure I fully understand the documentation for creating exhibit themes ( http://omeka.org/codex/Creating_an_Exhibit_Theme ).

  1. Where do I put new/modified layout template files (i.e. new versions of the files found at views/public/shared/exhibit_layouts)? Or is this not supported?
  2. Can I use functions declared in custom.php?

Basically, all the changes I would like to make involve those layout files, where I just need to modify some minor things. Right now, I've hacked 2 functions in helpers/ExhibitFunctions.php.

The best case would be to simply override those plugin functions in my theme custom.php file. Specifically, these (I just edited the $title variable for use in fancy tooltips):

  1. exhibit_builder_display_exhibit_thumbnail_gallery()
  2. exhibit_builder_exhibit_display_item()

Okay, I tried using add_filter() to modify those plugin functions like so, but something is preventing the images/files from displaying. The $title is printing in place of the image unless I remove the return lines in which case no files display. I'm guessing this is an obvious syntax error or something?

/*
filtering ExhibitBuilder functions
*/
add_filter('exhibit_builder_exhibit_display_item','deco_exhibit_builder_exhibit_display_item');
add_filter('exhibit_builder_display_exhibit_thumbnail_gallery','deco_exhibit_builder_display_exhibit_thumbnail_gallery');

function deco_exhibit_builder_exhibit_display_item($title)
{
$title='<h3>'.item('Dublin Core', 'Title', array('snippet'=>80), $item).'</h3><p>'.item('Dublin Core', 'Description',array('snippet'=>240)).'<br/><a href="'.item('permalink').'"target="_blank">View Full Record</a></p>';
return $title;
}

function deco_exhibit_builder_display_exhibit_thumbnail_gallery($title)
{
$title='<h3>'.item('Dublin Core', 'Title',array('snippet'=>80), $item).'</h3><p>'.item('Dublin Core', 'Description',array('snippet'=>240)).'<br/><a href="'.item('permalink').'"target="_blank">View Full Record</a></p>';
return $title;
}

Those filters you're using are designed to allow you to completely replace the HTML that the functions would normally return. What you return from your filter function completely replaces the HTML that would otherwise be output.

They also don't quite take the same parameters you've used here. The first, and only required parameter is $html, the HTML that would otherwise have been output. The rest of the arguments are the normal arguments to the exhibit function being filtered.

If you do have totally new versions of these functions already, you can put those whole implementations in your filter functions and get the results you're looking for.

I'm getting Zend_Controller_Router_Exception - id is not specified on deco_exhibit_builder_exhibit_display_item() and Apache 500 Error on deco_exhibit_builder_display_exhibit_thumbnail_gallery(). Here's what I'm using, which works fine when placed directly into the plugin code:

/*
filtering ExhibitBuilder functions
new functions are identical to originals except where 'hacked' appears (in $title vars)
*/
add_filter('exhibit_builder_exhibit_display_item','deco_exhibit_builder_exhibit_display_item');
add_filter('exhibit_builder_display_exhibit_thumbnail_gallery','deco_exhibit_builder_display_exhibit_thumbnail_gallery');

function deco_exhibit_builder_display_exhibit_thumbnail_gallery($start, $end, $props = array(), $thumbnailType = 'square_thumbnail')
{
    $html = '';
    for ($i=(int)$start; $i <= (int)$end; $i++) {
        if (exhibit_builder_use_exhibit_page_item($i)) {
            $html .= "\n" . '<div class="exhibit-item">';
            //hacked by @ebellempire
            $title='<h3>'.item('Dublin Core', 'Title',array('snippet'=>80), $item).'</h3><p>'.item('Dublin Core', 'Description',array('snippet'=>240)).'<br/><a href="'.item('permalink').'"target="_blank">View Full Record</a></p>';
            $thumbnail = item_image($thumbnailType, array('title'=>$title));
            $html .= exhibit_builder_link_to_exhibit_item($thumbnail);
            $html .= exhibit_builder_exhibit_display_caption($i);
            $html .= '</div>' . "\n";
        }
    }
    $html = apply_filters('exhibit_builder_display_exhibit_thumbnail_gallery', $html, $start, $end, $props, $thumbnailType);
    return $html;
}

function deco_exhibit_builder_exhibit_display_item($displayFilesOptions = array(), $linkProperties = array(), $item = null)
{
    if (!$item) {
        $item = get_current_item();
    }

    // Always just display the first file (may change this in future).
    $fileIndex = 0;

    // Default link href points to the exhibit item page.
    if (!isset($displayFilesOptions['linkAttributes']['href'])) {
        $displayFilesOptions['linkAttributes']['href'] = exhibit_builder_exhibit_item_uri($item);
    }

    // Default alt text is the
    if(!isset($displayFileOptions['imgAttributes']['alt'])) {
        $displayFilesOptions['imgAttributes']['alt'] = item('Dublin Core', 'Title', array(), $item);
    }
    // Default title text is the
    if(!isset($displayFileOptions['imgAttributes']['title'])) {
        //hacked by @ebellempire
    	$title='<h3>'.item('Dublin Core', 'Title', array('snippet'=>80), $item).'</h3><p>'.item('Dublin Core', 'Description',array('snippet'=>240)).'<br/><a href="'.item('permalink').'"target="_blank">View Full Record</a></p>';
        $displayFilesOptions['imgAttributes']['title'] = $title;
    }

    // Pass null as the 3rd arg so that it doesn't output the item-file div.
    $fileWrapperClass = null;
    $file = $item->Files[$fileIndex];
    if ($file) {
        $html = display_file($file, $displayFilesOptions, $fileWrapperClass);
    } else {
        $html = exhibit_builder_link_to_exhibit_item(null, $linkProperties, $item);
    }

    $html = apply_filters('exhibit_builder_exhibit_display_item', $html, $displayFilesOptions, $linkProperties, $item);

    return $html;
}

Oh, wait, I think I have it now.

Ok, actually I don't have it at all, though I'm pretty sure it has something to do with the apply_filters() line.

A few things:

  • You almost certainly don't want to be calling apply_filters in your filter functions. If you weren't having errors, I'd expect this to cause an infinite loop.
  • The obvious issue here is that the first parameter to the filter functions is $html, then followed by the normal parameters for the functions. Just putting $html at the front of your parameter lists for both those functions might resolve your problems.

Yep, that did it. I tried both of those before, just not at the same time apparently? I suppose it always helps to not be guessing. As always, thanks for your help.

/*
filtering ExhibitBuilder functions
*/
add_filter('exhibit_builder_exhibit_display_item','deco_exhibit_builder_exhibit_display_item');
add_filter('exhibit_builder_display_exhibit_thumbnail_gallery','deco_exhibit_builder_display_exhibit_thumbnail_gallery');

function deco_exhibit_builder_display_exhibit_thumbnail_gallery($html, $start, $end, $props = array(), $thumbnailType = 'square_thumbnail')
{
    $html = '';
    for ($i=(int)$start; $i <= (int)$end; $i++) {
        if (exhibit_builder_use_exhibit_page_item($i)) {
            $html .= "\n" . '<div class="exhibit-item">';
            $title='<h3>'.item('Dublin Core', 'Title',array('snippet'=>80), $item).'</h3><p>'.item('Dublin Core', 'Description',array('snippet'=>240)).'<br/><a href="'.item('permalink').'"target="_blank">View Full Record</a></p>';
            $thumbnail = item_image($thumbnailType, array('title'=>$title));
            $html .= exhibit_builder_link_to_exhibit_item($thumbnail);
            $html .= exhibit_builder_exhibit_display_caption($i);
            $html .= '</div>' . "\n";
        }
    }
    return $html;
}

function deco_exhibit_builder_exhibit_display_item($html,$displayFilesOptions = array(), $linkProperties = array(), $item = null)
{
    if (!$item) {
        $item = get_current_item();
    }

    // Always just display the first file (may change this in future).
    $fileIndex = 0;

    // Default link href points to the exhibit item page.
    if (!isset($displayFilesOptions['linkAttributes']['href'])) {
        $displayFilesOptions['linkAttributes']['href'] = exhibit_builder_exhibit_item_uri($item);
    }

    // Default alt text is the
    if(!isset($displayFileOptions['imgAttributes']['alt'])) {
        $displayFilesOptions['imgAttributes']['alt'] = item('Dublin Core', 'Title', array(), $item);
    }
    // Default title text is the
    if(!isset($displayFileOptions['imgAttributes']['title'])) {
    	$title='<h3>'.item('Dublin Core', 'Title', array('snippet'=>80), $item).'</h3><p>'.item('Dublin Core', 'Description',array('snippet'=>240)).'<br/><a href="'.item('permalink').'"target="_blank">View Full Record</a></p>';
        $displayFilesOptions['imgAttributes']['title'] = $title;
    }

    // Pass null as the 3rd arg so that it doesn't output the item-file div.
    $fileWrapperClass = null;
    $file = $item->Files[$fileIndex];
    if ($file) {
        $html = display_file($file, $displayFilesOptions, $fileWrapperClass);
    } else {
        $html = exhibit_builder_link_to_exhibit_item(null, $linkProperties, $item);
    }

    return $html;
}