Displaying the first image out of an array, thickbox linking to the rest of the images

brentor - October 2, 2008 - 00:55
Project:PHPTemplate
Version:4.6.x-1.x-dev
Component:Code
Category:support request
Priority:critical
Assigned:brentor
Status:active
Description

Hi All,

Please see this link for clarification:

http://ballistixwip.com/_clientfiles/walton/project_type/fit_out_and_refurb

I've created a content type called 'Gallery' which has an image field called 'field_image_gallery', along with two text fields. I've created my own .tpl.php file for this content type and my aim is to display one image for each of the projects and thickbox link to the remaining images for each project. Each project has about 4-5 images associated to it. I currently have it setup so it displays one image per project however it links to the images on the page not all the images associated with an individual project.

I'm really struggling with the PHP even though I know it seems really simple I only have very limited PHP knowledge. Here is my PHP code I've been playing around with:

This is what i'm currently using, it displays the first image for each project and thickbox links to the rest of the images on the page not to the rest of the images for a project:
<?php print $field_image_gallery[0]['view']; ?>

I've tried this as well but it just displays all the images on the page for each project, so 3-4 images as thumbnails instead of just one, but this allows me to thickbox between them all.

<?php if ($field_image_gallery[0]['filename']): ?>
          <?php foreach ($field_image_gallery as $item) { ?>
            <?php print $item['view'] ?>
          <?php } ?>
<?php endif;  ?>

Bascially i need a combintion of the two snippets of code to display one image as a thumbnail and thickbox link to the remaining images for that project.

Really struggling here all help would be much appreciated!

Only a new drupal user I'm using drupal 5.1 not sure what version i should've used in the drop down as my version wasn't there only 4.6.x-1.x-dev and HEAD.

 
 

Drupal is a registered trademark of Dries Buytaert.