I'm using the following code to link my uploaded images (via imagefield) to a corresponding uploaded PDF (via filefield). So I have an imagefield and filefield on my content type form. I post both the image and file. Then via contemplate I have this code working:

<?php
print l($node->field_image1[0]['view'], $node->field_pdf1[0]['filepath'], array('html' => TRUE));
?>

where "field_image1" and "field_pdf1" are the names of the fields.

Now this works. However is it possible to force the PDF to open in a new resized and scrollable browser window? It opens in a new browser window in IE and new browser tab in Firefox. But I'd like to force it open in a smaller window that's scrollable. I know this is possible using javascript with an "onclick" but is it possible to code the above PHP to do this?

Additionally I've tried the following code as well to mimic the above (this was posted here on drupal.org as another method):

<a target="_blank" href="<?php print $node->field_pdf1[0]['view']; ?>"><?php print $node->field_image1[0]['view']; ?></a>

Any suggestions would be most helpful.

Thanks in advance.

-backdrifting

Comments

ambientdrup’s picture

BTW - this is where the original instructions on how to do this with php is located:

http://drupal.org/node/281638

-backdrifting

markabur’s picture

well, you can add attributes to the link function, e.g.:

<?php
print l(
  $node->field_image1[0]['view'], 
  $node->field_pdf1[0]['filepath'], 
  array(
    'html' => TRUE, 
    'attributes' => array('target' => '_blank')
  )
);
?>
ambientdrup’s picture

Yes this works ... thanks. However, is it possible to add resize dimensions to the new browser window? I'd like to force that window open in a smaller dimension (width/height). Can these attributes be added to the array I have?

-backdrifting

markabur’s picture

you'd have to try it... you can put whatever key/value pairs you like in the attributes array (including an id, if you want to add some jquery indirectly).

hongpong’s picture

I found this when looking for how to print filepath CCK filefields. Like so, if field_episode is a filefield:

print $node->field_episode[0]['filepath']

markabur’s picture

yes, and since you're at the point of trying to figure out exactly what data is available and how to get at it, you should install the devel module so that you can see how to print *all* your fields, and anything else in the node you want.

<?php
// install and enable the devel module before trying this 
dpm($node);
?>