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.
We do have customer views field handlers to format our cent values in various ways and would love to see the same support for views_calc too. However, we haven't found a way yet to patch that ourselves.
I can imagine too ways of implementing this: Either make more views field handlers available for selection in the table settings or - even more elegantly - just use the same formatting for the totals that are used for the detail values. That would be most powerful. Is it also possible?
Comments
Comment #1
jurgenhaasNow found a very useful comment in the function views_calc_table_total() which states
I wasn't quite sure why that shouldn't work. Is it just because of possible caching? If that was the case, wouldn't it make sense to temporarily disable caching while processing those row(s) from views_calc?
If have now replaced
$vars[$key][$calc][$column] = number_format($row->$field_alias, $precision, $decimal, $separator);
with
$vars[$key][$calc][$column] = $fields[$field]->theme($row);
and that works perfectly fine for my case. I'd like to understand more about the limitations and maybe we can find a way to overcome them.