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

miles28’s picture

Well, I've got the same result with this simple code:

<a href="<?php print $node->field_link[0]['url'] ?> 
<?php print $node->field_file[0]['filepath'] ?>">
<?php print $node->field_image[0]['view'] ?></a>
glennr’s picture

Just want to thank you for posting your solution, miles28. So simple yet it saved me hours . . .