By GiRo on
In a viewfield I display a view containing a computed field that gets recalculated using an editable field that is contained in another viewfield/view in the same node.
To recalculate the computed field, I need to use the following codes:
In Computed Code: $node_field[0]['value'] = $node->nid;
In Display Format:
$node=node_load($node_field_item['value']);
$unitinterval = $node->field_unitinterval[0]['value'] ;
$unittime = $node->field_unittime[0]['value'] ;
$costpercall = $node->field_costpercall[0]['value'] ;
$unitprice = $node->field_unitprice[0]['value'] ;
$input1nid = $node->field_reference[0][nid];
$duration=db_result(db_query("SELECT field_input1_value FROM content_type_input WHERE nid=%d",$input1nid));
$display = number_format((ceil($duration * 60 / $unitinterval) * $unitprice / ($unittime * 60) * $unitinterval) + $costpercall,2, ".", "'");
That is working fine so far BUT it's not possible to get the computed results sorted. Actually the items in the view can get sorted using the computed field, but then the sorting is done by node ID. That happens most probably because of the code in the 'Computed Code' field: $node_field[0]['value'] = $node->nid;
Is there anybody who knows some workaround for that problem?