Hi,

I'm using cck + contemplate + imagecache + thickbox(or trying to use thickbox)

I have successfully set up a cck type, which includes an image field with multiple values allowed (so in my test I have a cck image field with 6 images). I have set up imagecache to produce a "thumb" plus an "enlarge" image.

I've also successfully used contemplate to display the thumbs in a row by using the theme function below.

My Images

foreach ((array)$field_details_page_image_1 as $item) {
print theme('imagecache', 'details_page_images_thumb', $item['filepath']);
}

At the moment then I have 6 image thumbs displayed in my cck node display. But I need these to be pop up linking to the "enlarge" imagecache presets, which I believe could be achieved using thickbox.

I've been trying to use the theme function "theme_imagefield_image_imagecache_thickbox", but either that's the wrong thing to do, or I just don't know what parameters it's expecting from me.

function theme_imagefield_image_imagecache_thickbox($namespace, $field, $path, $alt = '', $title = '', $attributes = NULL) {

I guess I should know what the above mean, but alas I don't !

Can anyone help... is this the right theme function to use from within contemplate and if so, any tips on those parameters ?

Thanks

Rob

Comments

Miteto’s picture

There was a patch contributed while ago - http://drupal.org/node/112850 which explained how things must be done. Thickbox module has changed since and things became easier - just make a copy of thickbox.module and rename it to thickbox.module.imagefield_0. All thats left to do is to change your imagecache preset from thumb to the newly (automatically) created preset Thickbox: thumb.

pcmeissner’s picture

I've tried to get this to work but have had limited success. So what is the correct syntax for accomplishing a node specific gallery. So far I've tried this...

<?php
foreach ((array)$field_image as $item) {
?>
<?php
print theme_imagefield_image_imagecache_thickbox('imagecache', 'Thickbox: thumb', $item['filepath']);
?>
<?php
}
?>

When I use the above code I can see the links, and thickbox works; however, the thumbnails don't show up only missing jpgs (the path to the thumb jpegs is wrong). I am using all the prerequisite modules, and have defined a "thumb" preset in imagecache. Any pointers.

I also tried to get the same effect using Views. I set up a View to output the Thickbox: thumbs in a grid in a block which I place in my template. That works great; however, the View outputs all of the images attached to every node created, and I don't know of way to filter the results that would only show the images attached to the current node.

Any help would be appreciated.

Miteto’s picture

Since I'm a complete newbie to PHP and Drupal, all I can share is what worked for me:

<?php foreach ((array)$field_image as $item) { ?>
       <div class="field-item"><?php print $item['view'] ?></div>
       <?php } ?>

If you need more here is the complete stuff:

<div class="content">
   <div class="fieldgroup group-images" style="float:right;">
    <div class="field field-type-image field-field-image">
      <div class="field-items">
       <?php foreach ((array)$field_image as $item) { ?>
       <div class="field-item"><?php print $item['view'] ?></div>
       <?php } ?>
      </div>
    </div>
	
	<div class="field field-type-image field-field-image2">
      <div class="field-items">
       <?php foreach ((array)$field_image2 as $item) { ?>
       <div class="field-item" style="display:inline;"><?php print $item['view'] ?></div>
       <?php } ?>
      </div>
    </div>
   </div>
	
   <div class="field field-type-text field-field-tbox">
    <div class="field-items">
     <?php foreach ((array)$field_tbox as $item) { ?>
     <div class="field-item"><?php print $item['view'] ?></div>
     <?php } ?>
    </div>
   </div>
  </div>

In this template I ommited the body field and used a text field insted. I made a couple of imagefields then i grouped them. The group appears in the upper right corner as stated in the code - style="float:right;". The first imagefield named "image" displays a single large thumbnail and the second imagefield shows multiple small thumbnails displayed in a row right below the first imagefield as stated in code - style="display:inline;". The text field wrapps around the imagefield group.

pcmeissner’s picture

Thanks for the help, but that wasn't quite the solution I was looing for. After some more trial and error, I discovered that all I needed to do was change this line...

print theme_imagefield_image_imagecache_thickbox('imagecache', 'Thickbox: thumb', $item['filepath'
to
print theme_imagefield_image_imagecache_thickbox('thumb', 'Thickbox: thumb', $item['filepath'

...works great now.