<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>@David&nbsp;Metzler</div><div><br></div><div>Thank you!!&nbsp;your solution worked but with&nbsp;modification.</div></div></span></div><div><br></div><div>This caused an error:</div><div><blockquote type="cite">if ($node->$node->field_file[0]['filepath']) print l(t('Download<br>Article'), file_create_url($node->field_file[0]['filepath']));</blockquote><div><br></div><div>recoverable fatal error: Object of class stdClass could not be converted to string</div><div><br></div><div>but i removed the first $node-> to have this:</div><div><br></div><blockquote type="cite">if ($node->field_file[0]['filepath']) print l(t('Download<br>Article'), file_create_url($node->field_file[0]['filepath']));</blockquote><div><br></div><div>and it worked! thank you, im still learning PHP syntax and didnt know how to do a simple if else statement like this.</div><div><br></div><div>@Francisco, the reason i didn't go with standard drupal behavior is because i didn't want the title of the node to be the link text. That is how it was showing up in my configuration when i selected Generic Files. If there is a way to take take the Label and make it a link to the file in the CCK manage fields admin dialog, i would love to learn about it.</div><div><br></div><div>thanks so much for everyone's help.</div><div>andrea</div><br><div><blockquote type="cite"><div><font class="Apple-style-span" color="#000000"><br></font><br>Message: 4<br>Date: Thu, 4 Jun 2009 09:50:58 -0700<br>From: andrea burton &lt;<a href="mailto:andrea.burton@gmail.com">andrea.burton@gmail.com</a>><br>Subject: [support] Calling a field in a node template - need PHP help<br>To: <a href="mailto:support@drupal.org">support@drupal.org</a><br>Message-ID: &lt;<a href="mailto:D8BC1E3E-464D-4962-AB73-0047F1CFDD72@gmail.com">D8BC1E3E-464D-4962-AB73-0047F1CFDD72@gmail.com</a>><br>Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes<br><br>Hi,<br><br>I am stuck on this problem.<br><br>I have a News content type with a File field called field_file.<br><br>I am trying to figure out how to write the code in the node- <br>news.tpl.php to show the field but only if a file has been uploaded &nbsp;<br>and thus filled that field.<br><br>Right now, I have this code to pull in the body and the file_field:<br><br>print $body;<br>print l(t('Download Article'), file_create_url($node->field_file[0] <br>['filepath']));<br><br>but "Download Article" shows up in the nodes that do not have a file &nbsp;<br>uploaded into that node.<br><br>Im thinking all i need is an if-else statement that says:<br><br>If field_file exists, then print l(t('Download Article'), &nbsp;<br>file_create_url($node->field_file[0]['filepath']));<br>else just print $body<br><br>but nothing i have tried works.<br><br>Can anyone help me?<br><br>thanks!<br>andrea<br><br><br><br>------------------------------<br><br>Message: 5<br>Date: Thu, 4 Jun 2009 19:33:36 +0200<br>From: Francesco &lt;<a href="mailto:entuland@gmail.com">entuland@gmail.com</a>><br>Subject: Re: [support] Calling a field in a node template - need PHP<br><span class="Apple-tab-span" style="white-space:pre">        </span>help<br>To: <a href="mailto:support@drupal.org">support@drupal.org</a><br>Message-ID:<br><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;<a href="mailto:5803c9860906041033h62604942hd13955cdd3e3137e@mail.gmail.com">5803c9860906041033h62604942hd13955cdd3e3137e@mail.gmail.com</a>><br>Content-Type: text/plain; charset=ISO-8859-1<br><br>Hi Andrea,<br><br><blockquote type="cite">I have a News content type with a File field called field_file.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I am trying to figure out how to write the code in the node-<br></blockquote><blockquote type="cite">news.tpl.php to show the field but only if a file has been uploaded<br></blockquote><blockquote type="cite">and thus filled that field.<br></blockquote><br>Why don't you rely on the standard behavior? Put the text "Download Article"<br>as the field label, and let Drupal show or hide them both (label and<br>field) depending on<br>the field content.<br><br>If you want finer control, go ahead and use php, but instead of<br>checking if field_file exists, check if item 0 is empty or not. The<br>fact is that item 0 of each field is always present, regardless of it<br>being filled or not.<br><br>Just my two cents, hope this helped.<br><br>Regards,<br>Francesco<br><br><br>------------------------------<br><br>Message: 6<br>Date: Thu, 4 Jun 2009 11:42:31 -0700<br>From: "Metzler, David" &lt;<a href="mailto:metzlerd@evergreen.edu">metzlerd@evergreen.edu</a>><br>Subject: Re: [support] Calling a field in a node template - need PHP<br><span class="Apple-tab-span" style="white-space:pre">        </span>help<br>To: &lt;<a href="mailto:support@drupal.org">support@drupal.org</a>><br>Message-ID:<br><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;<a href="mailto:52177C930FA90F4D9888B0343FDB79FBA58C0B@birch.evergreen.edu">52177C930FA90F4D9888B0343FDB79FBA58C0B@birch.evergreen.edu</a>><br>Content-Type: text/plain;<span class="Apple-tab-span" style="white-space:pre">        </span>charset="us-ascii"<br><br>I'm not 100% sure but have you tried this? <br><br>if ($node->$node->field_file[0]['filepath']) print l(t('Download<br>Article'), file_create_url($node->field_file[0]['filepath']));<br><br><br></div></blockquote></div><br></div></body></html>