Drupal Views PHP and Text Values

Man, after much tinkering and frustration I have finally realized that when using Views PHP to construct fields you cannot print actual text values out. Instead it will produce the entity number in your output code.

So, in case you are trying to get a Global PHP field to write out an actual value from your database using a $row variable it’s not going to work. You’ll end up with the entity number instead of the text you’re retrieving. Either you have to use a Global text field and available tokens or retrieve the raw text like this using $data:

<?php print ‘<p>This is the text here. And, here is your ‘ .$data->field_field_yourvalue[‘0’][‘raw’][‘value’]. ‘</p>’; ?>

Here’s some more detail on this if anyone is interested. http://drupal.org/node/1140896

Leave a Reply

Your email address will not be published. Required fields are marked *