Posted by esllou on November 25, 2008 at 9:08am
Jump to:
| Project: | Node Images |
| Version: | 5.x-1.x-dev |
| Component: | User interface |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I have a node type where each node will have 2 uploaded images...a sort of before and after.
How do I separate out these two images in my tpl.php file. If I use the standard:
<?php print $node->node_images ?>the two images come out together. Is there a way of dividing them up, into some sort of array and then calling [1], then [2]. The reason I need them separate is I have text that goes between them.
thanks.
Comments
#1
its a lol workaround but It works
<?php
// copy the div definition + contents
$node_images = $node->node_images;
// remove div definitions
$node_images = str_replace("<div class=\"node_images\">", "", $node_images);
$node_images = str_replace("</div>", "", $node_images);
// remove first "<a" and last "</a>"
$node_images = substr($node_images, 2, strlen($node_images) - 6);
// split the string to many ... images!
$node_images_array = explode("</a> <a", $node_images);
print "var text 0";
print "<a" . $node_images_array[0] . "</a>";
print "var text 1";
print "<a" . $node_images_array[1] . "</a>";
print "var text 2";
?>
It have been tested with 6.15 drupal + lightbox2 patch. I think that it is compatible with any version.
#2
How to show 1 image at the top and 3images at the bottom