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.
I'm trying to get my computed field to add up a bunch of fields in other nodes, which are nodereferrers to the "total" node. When I put this code in a computed field, I get the following error:
Invalid argument supplied for foreach() in /var/www/testsite1/sites/all/modules/contrib/computed_field/computed_field.module(161) : eval()'d code on line 3.
However, when I put the same code in the content template (contemplate module), and just "print" the $ticketcost, it works great. Any ideas?
Here's the code:
$mcs = $node->field_ticketexpenses[0]['items'];
$ticketcost = 0;
foreach($mcs as $key => $value){
$mc = 0;
$mcnid = $value['nid'];
$mc = db_result(db_query("SELECT field_cost_value FROM content_field_cost WHERE nid=" . $mcnid));
$ticketcost = $ticketcost + $mc;
}
$node_field[0]['value'] = $ticketcost;
Comments
Comment #1
mmjvb CreditAttribution: mmjvb as a volunteer commented