On this page
Output code
This is documentation for Drupal 7, which is no longer supported. Learn more and find resources for Drupal 7 sites
The Views PHP field contains a section labelled Output code where you can create output to be displayed by the field. The content starts in HTML mode and you can add PHP using the PHP element.
The following example prints a node title from a node row.
<?php print $row->title; ?>
The following example prints a node title from a node row within a heading.
<h2><?php print $row->title; ?></h2>
$value
Views PHP has a section to generate a value that will be returned to Views. The Output section follows the Value section and, in my test, the Output section shows the value from the Value section as $value. I can display $value in HTML using code such as the following.
<div style="background-color: #ccccff;"><?php print $value; ?></div>
The value is also added to $row as $row->php, something you can display as follows.
<div style="background-color: #ccffcc;"><?php print $row->php; ?></div>
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion