Trent Wyman


PHP if (!empty) function

Categories:

Here is a Drupal PHP example using !empty that checks to see if a particular field has content. If the field IS NOT empty, then display the contents of that field. Else, output a text string.

Example:

<?php
// Setup a variable
$crop = $node->field_cheer_three_photo_crop[0]['view'];

if(!empty($crop)){
print $node->field_cheer_three_photo_crop[0]['view'];
}else{
print 'There is no data to display';
}

?>


Announcements

DrupalCon Denver 2012 - I'm Going!

Press Release:
Michael C. Carlos Museum

Read the press release announcing the Drupal redesign of Emory University's Michael C. Carlos Museum. View Press Release