Two options, only one result

miles28 - June 28, 2008 - 10:38
Project:Content Templates (Contemplate)
Version:5.x-2.02
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

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

#1

miles28 - June 29, 2008 - 11:24

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>

#2

glennr - June 24, 2009 - 05:09

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

 
 

Drupal is a registered trademark of Dries Buytaert.