function for displaying exhibit item thumbnail?

135 views
Skip to first unread message

Jonathan Reeve

unread,
Jul 24, 2012, 2:29:20 PM7/24/12
to omek...@googlegroups.com
Hi everyone,

I'm making a new Omeka theme, and one of the things I'm trying to do is display thumbnails for exhibits. That's to say, I'd like the "Browse Exhibits" page to display associated images for each exhibit. I copied the Exhibit Builder plugin's exhibits/browse.php to my theme directory, and it seems to be working, but I can't seem to find a function that will allow me to display a thumbnail image of an item associated with an exhibit. Ideally, I'd like for the "Browse Exhibits" summary of the exhibit to contain a title, description, thumbnail image, and tags, but right now it only displays title, description, tags. It seems like it'd be easy to get the first thumbnail from the first item in the exhibit, but I can't seem to select it correctly. 

So far I've tried adding this code to browse.php, after the <h2> line: 

    <div class="exhibitImage"><?php echo exhibit_builder_exhibit_thumbnail(1); ?></div>

but I get: 

    Zend_Controller_Router_Exception: section_slug is not specified

I also tried: 

                <div class="exhibitImage">
<?php set_current_item(get_item_by_id(1)); ?>
<?php echo exhibit_builder_exhibit_display_item(); ?>
</div>  

but I get: 

    Catchable fatal error: Argument 1 passed to set_current_item() must be an instance of Item, null given,

Please forgive my lack of knowledge about this--I'm still working my way through the Omeka API. What I'd like to know is, is there a function for displaying an image from an exhibit? If so, how do I 1) select the first item in the currently selected (looping) exhibit? 2) Display the thumbnail from that item? Any help would be greatly appreciated. 

-Jon Reeve

nancy moussa

unread,
Jul 25, 2012, 3:54:50 PM7/25/12
to omek...@googlegroups.com, jon....@gmail.com
Hi Jon,

Here is what I am doing to display the image from first item in first page in exhibit hope it help.
Maybe there is a better way to do that, but you can try this.

  $itemcount=0;
      $page="";
      $section = $exhibitobject->getFirstSection();
      if(!empty($section)){
          $page= $exhibitobject->getFirstSection()->getPageByOrder(1);
      $itemcount = count($page['ExhibitPageEntry']);
   
     $itempageobject = $page['ExhibitPageEntry'];
    $found=false;
    if($itemcount>0){
    for ($i=1; $i <= $itemcount; $i++) {
    if($found!=true){
        $item = $itempageobject[$i]['Item'];
        if(!empty($item)){
             while (loop_files_for_item($item)):
                            $file = get_current_file();                                            
                            //print_r($file['archive_filename']);
                            //exit;
                            if ($file->hasThumbnail()):               
                                if ($index == 0):                       
                                     $Exhibit_image = array('image'=>'/'.$file->getStoragePath('fullsize'),'title'=>item('Dublin Core','Title',array(),$item));
                                //     print_r($file->getStoragePath('fullsize'));
                                //     exit;
                                     $index=1;
                                     $found=true;
                                 endif;
                            endif;
            endwhile;
            }                   
        }
    }
    }


Nancy

Date: Tue, 24 Jul 2012 14:29:20 -0400
Subject: [omeka-dev] function for displaying exhibit item thumbnail?
From: jon....@gmail.com
To: omek...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "Omeka Dev" group.
To post to this group, send email to omek...@googlegroups.com.
To unsubscribe from this group, send email to omeka-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/omeka-dev?hl=en.

Walter Rice

unread,
Aug 31, 2012, 7:28:13 PM8/31/12
to omek...@googlegroups.com
Followup a month later.  I've modified this concept to iterate through all the pages of an exhibit (in order) and grab the first image, which I use for the thumbnail on the exhibit browse page.
  

$imgurl = "";

foreach ($exhibit->Sections as $exhibitSection) 
{
// echo "\n   <!-- get next section -->";
if ($exhibitSection->hasPages()) 
{
foreach ($exhibitSection->Pages as $exhibitPage) 
{
// echo "\n      <!-- get next page, " . $exhibitPage->title . " -->";
for ($i = 1; $i <= count($exhibitPage['ExhibitPageEntry']); $i++)
{
$item = exhibit_builder_page_item($i, $exhibitPage);
// echo "\n         <!-- get next item, has " . count($item->Files) . " files -->";
if (count($item->Files) > 0)
{
foreach ($item->Files as $file)
{
// echo "\n            <!-- get next file, mime type: " . $file->getMimeType() . " -->";
if ($file->hasThumbnail())
{
  $imgurl = $file->getWebPath('fullsize');
  break;
}
}
}
if ($imgurl != "") break;
}
if ($imgurl != "") break;
}
}
if ($imgurl != "") break;
}





On Wed, Jul 25, 2012 at 3:54 PM, nancy moussa <nancy_...@hotmail.com> wrote:
Hi Jon,

Here is what I am doing to display the image from first item in first page in exhibit hope it help.
Maybe there is a better way to do that, but you can try this.

..



--
Walter R. Rice, Jr.
R&R Computer Solutions
118 E. Louden St.
Philadelphia, PA 19120

Cell: (215) 820-0165
Office: (215) 457-2921
E-mail: WaltR...@gmail.com

Reply all
Reply to author
Forward
0 new messages