Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Fields created with Views PHP cannot be aggregated.
Example: In View based on node there's a NID field. I'm adding a 2nd field (Views PHP) with:
Value code: return ($row->nid % 2) ? 0 : $row->nid; // Show even NIDs or zero.
Output code: <?php print $value; ?>
Field looks OK but after turning ON aggregation and set the aggregation to SUM on both columns, both will show the SUM of all NIDs... The Views PHP field should show the SUM of even NIDs.
Comments
Comment #1
patchshorts CreditAttribution: patchshorts commentedConfirmed this is a problem. Out put code can be return 1; and you set aggregation to on and the field to count, the whole table disappears for me.
Comment #2
quickly CreditAttribution: quickly commentedI am having similar issue... PHP is giving the right output but when aggregation is turned on there is no aggregation...
Comment #3
quickly CreditAttribution: quickly commentedjust checked the forums of Views Calc... Views Calc and Views php are not compatible... views calc generates queries on database, it cannot perform aggregation for any custom/global field..
Comment #3.0
quickly CreditAttribution: quickly commentedSmall fix on the code comment.