Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
How could I get the next code works?
I want to show a image linking to an url or an uploaded file, depending if I give an url or a link. I'm using three cck fields: imagecache, link and file.
I've put the following code in the node contemplate:
<?php if ($field_file): ?>
<a href="<?php print $node->field_file[0]['filepath'] ?>"><?php print $node->field_image[0]['view'] ?></a>
<?php endif; ?>
<?php if ($node->field_link): ?>
<a href="<?php print $node->field_link[0]['url'] ?>"><?php print $node->field_image[0]['view'] ?></a>
<?php endif; ?>
Thanks in advance
Comments
Comment #1
miles28 CreditAttribution: miles28 commentedWell, I've got the same result with this simple code:
Comment #2
glennr CreditAttribution: glennr commentedJust want to thank you for posting your solution, miles28. So simple yet it saved me hours . . .