Hi, I'm trying to create a clickable link with Lighbox2 and contemplate. I have read all the posts, but can't get it to work. I just want to have text that says "Views slideshow" and opens the Lightbox slideshow. The link is on the main page of content so I am using Contemplate and modifying the link in the body area.

Here's what I have done:

field_image_gallery is the CCK field, a repeating field that is part of the content type.

<a href="http://domain.com/<?php print $node->field_image_gallery[0]['filepath'] ?>" rel="lightbox[<?php print $node->field_image_gallery[0]['fid'] ?>][<?php print $node->field_image_gallery[0]['data']['title'] ?>]">Shows only one image - title </a>

This is the filepath: print $node->field_image_gallery[0]['filepath']
This is the group: print $node->field_image_gallery[0]['fid']
This is the caption or title: print $node->field_image_gallery[0]['data']['title']

This opens the lightbox window with the first window and the caption below the image. The Next arrow displays to the right. Clicking on the next arrow, there is no image and the same caption displays as the first picture/page. Also, it only indicates there are 2 images, where there are really 8.

Any help is appreciated.

Comments

nflowers1228’s picture

I got this to work. The biggest issue was that I was pointing to the field id (fid) instead of the node id (nid). But I also needed to keep the basic code that referenced all the links and then hide them with CSS. :-) Here is exactly what I did:

1) Created the link that is used on the main page, with the text "View slideshow". In the rel statement, I put:

  • the nid as the group name [<?php print $node->field_image_gallery[0]['nid'] ?>]
  • and the title [<?php print $node->field_image_gallery[0]['data']['title'] ?>] in the brackets as the caption text.

<a href="http://domain.com/<?php print $node->field_image_gallery[0]['filepath'] ?>" rel="lightbox[<?php print $node->field_image_gallery[0]['nid'] ?>] [<?php print $node->field_image_gallery[0]['data']['title'] ?>]">View slideshow </a>

2) In addition, I needed to keep the reference to the full slideshow using the foreach statement. This displays as multiple links directly underneath the "View slideshow" link created above.

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

3) Created the CSS to hide the links that display in step #2.

.image-gallery-hidden {
display: none;
}