I'm working on a photographer's site where he wants to sell high-quality prints of the pictures we're displaying. I've added a CCK Link field to the Image content type, to allow the photographer to put in a URL to the matching page on Imagekind where the viewer can purchase a print. I can display that link on the normal node display just fine. But it would be even better if the viewer could click on that link right there in the Lightbox, even ideally replacing the link to the normal node display.

The goal would be to more immediately link the experience of viewing the picture in the Lightbox format with the purchasing opportunity. I had hoped that there would be a way to use some kind of tpl.php file to dictate exactly how the Lightbox displays, but it doesn't look like the Lightbox display is that kind of themeable object.

Is there a way to do what I'm after--to add CCK field content to the imageDataContainer area?

Thanks.

Comments

stella’s picture

Status: Active » Fixed

I'm not totally sure what you're asking. I'm not sure if you (a) want to add a link cck field to a node and when it's clicked have the target url open in a lightbox or (b) add a link into the lightbox.

Assuming the first option, and assuming you're using the link field provided by the Link CCK module, the following steps should work.

  1. Add a link field to your custom content type.
  2. When adding the link field, and again when configuring the field via the "manage fields" tab, it is possible to specify a rel attribute.
  3. Set the rel attribute to one of the lightbox values, e.g lightbox or lightshow for image links, lightframe for external sites, lightmodal for relative paths to files on the same domain, or lightvideo to supported 3rd party video sites.
  4. In the rel attribute, you may also need to set the group name for grouped or slideshow images, e.g. lightbox[groupname], or you may need to set a caption, e.g. lightbox[groupname][caption]. Full details on all the different valid syntaxes are available at http://drupal.org/node/144488
  5. Detailed at the above url is how to include links in the caption text which might suit your needs.

Assuming (b), no it's not possible to add cck fields to the lightbox because the lightbox is not a node, just a method of displaying images, videos or full nodes. If you want to just add a link to the image caption, then use the method described in the docs at http://drupal.org/node/144488. If you want to display the full image node in the lightbox, then details on that are also provided in the same docs.

Hope this helps.

Cheers,
Stella

bw@brianwest.com’s picture

I greatly appreciate your explanation. You may have already answered my question (I think the answer is "b" above), but let me reword my question to be sure. An example...

If you edit node 228, you can enter a title, an image, categories (Acidfree galleries), body, and a purchase_url field (via CCK Link). If you enter a URL in the purchase_url field, and if a visitor to the site views node 228 in a normal Drupal way, that URL will display as a link beneath the image. But if instead the visitor goes to a gallery displaying a thumbnail for node 228's image, and they click on that thumbnail, a Lightbox representation of that image comes up, including a caption (pulled from the node's Title field) and a Link that, if clicked, will take a user to the normal Drupal presentation of node 228 (see above). This is basically default Lightbox2 behavior.

"All" I want to do is to change the Link in the Lightbox presentation so it sends the visitor to the URL designated in node 228's purchase_url field instead of sending them to the normal Drupal presentation of node 228.

It's sounding to me like the only way to make this happen is to customize page-node-lightbox2.tpl.php to include the purchase_url data, and then somehow change the link in the Acidfree gallery thumbnail to point to the /lightbox2 version of that node.

Is this making any sense, and is there some other way I'm missing? Thanks again.

stella’s picture

Yep, that's what you need to do. Customise page-node-lightbox2.tpl.php so it displays what you want - you may also need a node-lightbox2.tpl.php The page one is for the full page layout, with or without sidebars, etc, the node one is for customising which bits of the node content is displayed and where. More details on the templates can be found in the theming section of the handbook.

In order to display the full node in the lightbox, rather than just an image and caption, set the automatic image handler to "HTML content" for image nodes on admin/settings/lightbox2/automatic

Cheers,
Stella

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.