Hide header if node body is empty - Drupal php snippet help

Posted by Toxid on Stack Overflow See other posts from Stack Overflow or by Toxid
Published on 2010-05-06T20:59:12Z Indexed on 2010/05/06 21:08 UTC
Read the original article Hit count: 198

Filed under:
|
|

Hello! I've made a content type for links, I'm trying to make a link directory. People only have to submit the link, description is voluntary. If no description is entered, I want the header that says "description" to disappear. The description field is the node body. Right now my snippet looks like this

<?php if (!empty($node->body)) {?> 
<div class="field field-type-link field-field-link-archive">
<h3>Description</h3>
<?php print $node->content['body']['#value'] ?></div>
<?php }?>

I expect this to check if node body is not empty, and if it isn't it'll print what's there. The problem is that the Description header is still printed out even if the node body is empty. Can anyone see what's wrong?

© Stack Overflow or respective owner

Related posts about php

Related posts about drupal