How can I print something only when cck field has certain value on node.tpl.php? I need to print something conditionally in my node.tpl.php depending on the cck value of a field on my content type.

For example, if field_color has "red" or "blue", then print "It has color" and if it has other values print empty text.
The following should work:

if (isset($node-&gt;field_color[0]['value'])) {
  //If you want the field value to be displayed      
  print $node-&gt;field_color[0]['value'];
  //If you want some custom text to be displayed
  print 'It has colour';
} 
else {
  print 'Empty Text';
}


Or with ternary operators:

print (!empty($node-&gt;field_color[0]['value']) ? $node-&gt;field_color[0]['value'] : 'Empty text';


You'll probably either want to put in some logic to make sure the field exists though, or create a node-TYPE.tpl.php for your specific content type.

EDIT

This should sort out your red or blue issue:

if (isset($node-&gt;field_color[0]['value'])) {

  $colour_value = $node-&gt;field_color[0]['value'];

  if ($colour_value == 'red' || $colour_value == 'blue') {
    $colour = $colour_value;
  }
}

print (isset($colour)) ? $colour : t('Empty Text');


I've only put the field value into a variable to save space - you don't have to do this if you don't want to :-)