I'm displaying some CCK fields and doing a check_plain on them. I want to set a
tag somewhere within the check_plain so that it only happens if there is data in the field, but I don't really know how to go about it.

Here is the code that I have now, and you'll see that the
tag will always happen, which is not what I want:


<?php print check_plain($node->field_vendor_contact_person_2[0]['value']) ?> <br> <?php print check_plain($node->field_contact_person_email[0]['value']) ?>

Thanks for any help.

Comments

johnpitcairn’s picture

I'd probably go for something like:

<?php 
  print check_plain($node->field_vendor_contact_person_2[0]['value']);
  print ($email = $node->field_contact_person_email[0]['value']) ? '<br />' . check_plain($email) : '';
?>
TonyV’s picture

Thanks so much. I'll give that a try.