Hi. I've created a content type with two fields, one is an image field and the other one is a file field. What I want is to upload a pdf file and an imagefile, but then not to show the filefield, only the imagefile, so you can click on the imagefield and open the pdf file.

I think this could be done with contemplate like this:

<a href="<?php print $node->field_filefield[0]['view'] ?>">
  <?php print $node->field_imagefield[0]['view'] ?>
</a>

Obviously this doesn't work at all.

Any help?

Thanks in advance

Luis

Comments

lelizondo’s picture

Status: Active » Fixed

Done it.

<a href="/<?php print $node->field_filefield[0]['filepath'] ?>">
<?php print $node->field_imagefield[0]['view'] ?>
</a>

note the "/"... without it, I just got the filepath but not relative to the drupal site

Luis

lelizondo’s picture

ok.. the right way to do it is:

<a href="<?php print base_path() ?><?php print $node->field_filefield[0]['filepath'] ?>"><?php print $node->field_imagefield[0]['view'] ?></a>

forget about my previous post.

Luis

aaron’s picture

the following would be preferable in most cases:

print l($node->field_imagefield[0]['view'], $node->field_filefield[0]['filepath'], array(), NULL, NULL, FALSE, TRUE);

(in d6):

print l($node->field_imagefield[0]['view'], $node->field_filefield[0]['filepath'], array('html' => TRUE));
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.