Our Drupal distribution is to be used with different currencies defined by a custom variable...when we display nodes in a view with the price field we don't add the currency prefix...i want to add it through im guessing hook_views_pre_render? How can i inject a prefix using my custom variable?

This is what one of our views looks like

This is what i am thinking:

if (in_array($view->name, $views_with_prices)) {
foreach ($view->result as $activity) {
  $price = $activity->_field_data['nid']['entity']->field_average_price['und'][0]['value'];
  if ($price != 0) {
    $activity->_field_data['nid']['entity']->field_average_price['und'][0]['value'] = variable_get('my_currency') .  $activity->_field_data['nid']['entity']->field_average_price['und'][0]['value'];

but ideally i'd like to use a specific prefix functionality that comes with cck fields if possible or views equivalent.


I would do it by creating a template file, like views-view-field--fieldname.tpl.php, for the field and add the currency prefix to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.