I'm not 100% sure but have you tried this?
if ($node->$node->field_file[0]['filepath']) print l(t('Download Article'), file_create_url($node->field_file[0]['filepath']));
-----Original Message----- From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of andrea burton Sent: Thursday, June 04, 2009 9:51 AM To: support@drupal.org Subject: [support] Calling a field in a node template - need PHP help
Hi,
I am stuck on this problem.
I have a News content type with a File field called field_file.
I am trying to figure out how to write the code in the node- news.tpl.php to show the field but only if a file has been uploaded and thus filled that field.
Right now, I have this code to pull in the body and the file_field:
print $body; print l(t('Download Article'), file_create_url($node->field_file[0] ['filepath']));
but "Download Article" shows up in the nodes that do not have a file uploaded into that node.
Im thinking all i need is an if-else statement that says:
If field_file exists, then print l(t('Download Article'), file_create_url($node->field_file[0]['filepath'])); else just print $body
but nothing i have tried works.
Can anyone help me?
thanks! andrea
-- [ Drupal support list | http://lists.drupal.org/ ]