[support] Calling a field in a node template - need PHP help

andrea burton andrea.burton at gmail.com
Thu Jun 4 16:50:58 UTC 2009


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



More information about the support mailing list