Hi,

Am trying to set a node body to display using the content template module.
Would like to intoduce a line between 2 cck fields and to have an icon displayed in the beginning of the lower cck field mn_facts.Could do this with content template module and the code shown as Body Template is:

<?php print $node->content['body']['#value'] ?><table> <tbody><tr> <td><img alt="image" width="20" src="http://www.example.com/sites/default/files/note.svg" /><?php print check_plain($node->field_mn_facts[0]['value']) ?></td> </tr> </tbody></table>

The issue is, even when the cck field mn_facts is empty the icon is displayed.Is there a way to hide the icon too, when cck field is empty?

The images of 2 nodes when set to display with the same template code given above are attached.
1.gif shows the node display when the cck field mn_facts has content and 2.gif when it is empty.

Have phrased this issue similar to http://drupal.org/node/79188

-thank you

CommentFileSizeAuthor
2.gif5.76 KBnirvanajyothi
1.gif9.65 KBnirvanajyothi

Comments

stephtek’s picture

following. I have the same problem.

Anonymous’s picture

You could always check to see if the field is empty as part of your code too,, something like the following, but being no expert, and until one comes along, its just a hint of what to look for

if (empty(field mn_facts)) {

}

or use if not empty

if(!empty(field_mn_facts))(

"do bit of code to show icon"

}

stephtek’s picture

Cant seem to figure that out?

stephtek’s picture

Figured it out for a field and an array:

<?php if ($node->field_dealer_ats[0]['filepath']){
print "<a href=\"../../../../drupal/" . $node->field_dealer_ats[0]['filepath'] . "\">" . "<img src=\"../../../../../drupal/sites/all/themes/sitka/images/excel-file.gif\"> ATS</a>" . "&nbsp;&nbsp;&nbsp;";
}
?>
<?php if(sizeof($node->field_dealer_line_presentation) > 0){
 foreach($node->field_dealer_line_presentation as $dealer){
   if($dealer['view'] != ""){
     print "<br><br>Line Presentation<br>" . $dealer['view'];
   }
 }
}
?>
nirvanajyothi’s picture

Am adding the code that worked. Hope the template is alright. It also allows to add a background color in a table the dimensions of which can be changed.

<?php print $node->content['body']['#value'] ?><?php if(!empty($node->field_mn_facts[0]['value'])){?><table bgcolor="#99cccc" border="0.5" width="720"><tr>
<td><img alt="image" width="13" src="http://localhost/domain/sites/default/files/favicon.gif" /><?php print $node->field_mn_facts[0]['value'] ?></td>
</tr></table>
<?php } ?>

Thanks for all the hints.