I’m constructing a view in Drupal 7 with a field called “Content: Fruit”. If the value of that field is “lemon”, I want to change the output to “citrus”. How can I accomplish this?
Here’s what I tried:
First, I excluded the “Content: Fruit” field from the display. Then I added a “Global: PHP” field after it where, in the “Value code” section, I added:
return $row->field_fruit;
Then in the “Output code” section I added:
<?php if ($value == 'lemon') { print 'citrus'; } ?>
This doesn’t work. The value of $value
seems to be the node ID (“nid”).
Thought this would be straightforward… what am I doing wrong here? Is there a better way to accomplish this?