I’m trying to use a Views field template to insert PHP to convert a currency string to a number so that it can then be included in a math expression (can’t do math on a string), as seen here https://www.drupal.org/docs/7/modules/views/theming-a-single-field-in-a-views-3-template
The field name is
views_conditional and it outputs strings like “$2,560.00”. I created a new template file named
views-view-field--field-views-conditional.tpl.php with the following code in it and placed it in my theme’s folder:
<?php print (int)preg_replace("/..+$/i", "", preg_replace("/[^0-9.]/i", "", $output));
It is having no effect on the field output, so either the template is not being picked up or my code is wrong. Is there something I’m missing here?
Thanks in advance.