2

I'm working on a theme i bought and since i'm just learning php i'm having a hard time including a field as a description text in the lightbox once the thumbnail is clicked.

Here's the code (that's in the tpl.php file) that outputs the thumbnails (from a view)

<?php
if (isset($fields['field_image']->content) and strpos($fields['field_image']->content, '<img')) {
 print str_replace('<a ', '<a rel="prettyPhoto[gallery]" ', $fields['field_image']->content); ...
?>

Here's the html version of the lightbox script :

<a href="images/fullscreen/1.jpg" rel="prettyPhoto[gallery]" title="caption."><img ...

How can in include the caption tag ?

Thanks !!

1
<a title="caption"><img alt="description"></a>

Both the caption and the description will be displayed on the image preview.

| improve this answer | |
  • 1
    Hi, Thank you for the reply but i don't really understand what you said. The html version i used is just an example of how the script works. What i want is a way to dynamically include the caption in the php script. (the one that's in the tpl.php file) I can hardcode it and it would be something like this : print str_replace('<a ', '<a rel="prettyPhoto[gallery]" title="Hardcoded Caption" '... – amstram Jan 12 '12 at 3:33
  • Ok, so do you ask how to access a CCK field or how to embody a string in the lightbox frame ? – crenate Jan 12 '12 at 10:46
  • Yes i want to access a cck field and include it in the lightbox script as a caption Screenshot : [img.skitch.com/20120112-cihwefn7nq18ysu53uhruniui3.jpg] – amstram Jan 12 '12 at 18:58
  • Ok, there exist a basic approach to this problem. Type <pre><?php print_r($node); ?></pre> in node.tpl.php to see what's available in the node object (what fields, how formatted, etc.) and then take what you want and output it to the lightbox. I hope that's what you need.. – crenate Jan 13 '12 at 10:24
  • I fail to understand how this answer is helpful to the question asked. – Wtower Dec 29 '14 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.