views:

49

answers:

1

I'm using Drupal 6.x. This is my code on my node-product.tpl.php template. I've created a custom jquery gallery for the products. It works great, but I'm just missing tool tips from my images (both large and small thumbnails). To upload images I'm using a CCK field named field_images. There I input the image titles when I upload the images. How can I add the tool tip code snippet to make it work?

<div class="product-large">
<img src="/sites/default/files/imagecache/360x280/<?php print $node->field_images[0]['filename']; ?>" />
</div>

<div class="product-small">
   <?php
           // get all images
            foreach ($node->field_images as $images) {
        ?>
   <img src="/sites/default/files/imagecache/120x90/<?php print $images['filename']; ?>" rel="/sites/default/files/imagecache/360x280/<?php print $images['filename']; ?>" />
    <?php   
        }
        ?>
</div>

Thanks much appreciated!

Chris

+1  A: 

The "tooltip" is a result of the title HTML attribute. You'll want to add title="foo" to your img tag.

Perhaps: <img src="/sites/default/files/imagecache/120x90/<?php print $images['filename']; ?>" rel="/sites/default/files/imagecache/360x280/<?php print $images['data']['filename']; ?>" title="<?php print $images['title']; ?>"/> for the second image and similarly $node->field_images[0]['data']['title'] for the first.

greg
Hi Greg! I added title="<?php print $images[data]['title']; ?>" in the second php snippet under "product-small" and got the results for the product thumbnails. But I can't seem to get the tool tip to show up for the large image. If you'd like to take a look here is the link: http://gemini-lights.com/products/titan
Chris
This doesn't work when I add it to the top php snippet under "product-large".title="<?php print $node->field_images[data]['title']; ?>"It just outputs title=""
Chris
Try `$node->field_images[0]['data']['title']`. Also make sure you quote 'data'. Let me know and I will update my answer to match.
greg
Perfect!!! Thank you. It's works beautifully.
Chris
If you wouldn't mind and could spare a bit of time.. could you explain the why my code was wrong?
Chris
The second image tag is within the `for` loop that loops through the `field_images` array. The first `img` tag is not and so you are manually indexing to the first element of the array, apparently the full-sized image in this case. The `for` loop is basically auto-indexing for you which is why it is omitted in the second `img` tag.
greg