Resolving data in hook_views_data I have a custom table defined in hook_views_data().  One of my fields is an integer, which maps to some defined constants.  When they are queried and displayed by views, I'd like to change them to their string name that's represented by the integer.

So, my question is how can I manipulate values returned by views?
You can theme (you dont want to change the value stored in the DB, just change its displayed value) the view row value by using a template suggestion:


I prefer using a preprocessor function to do this on the field. This blog post covers how to do this for a specific view_name and field.

From the blogpost:


  There is an issue to let Drupal 7 and 8 themes implement a
  preprocess/process function per view as it is possible in Drupal 6,
  but it is in development (see issue).
  
  Until it is fixed there is a way to achieve that behaviour:


&lt;?php
/**
  * Generic preprocess that is still working on D7
  */
function MYTHEME_preprocess_views_view_fields(&amp;$vars) {
  if (isset($vars['view']-&gt;name)) {
    $function = __FUNCTION__ . '__' . $vars['view']-&gt;name . '__' . $vars['view']-&gt;current_display;

    if (function_exists($function)) {
     $function($vars);
    }
  }
}

/**
  * Then the specific preprocess that worked without the above code for D6
  */
function MYTHEME_preprocess_views_view_fields__VIEWNAME__DISPLAY(&amp;$vars) {
  // my specific preprocess code
}
?&gt;


There's also like views_custom_styles (sandbox project) and views_php which will let you do the same thing -- but for what you're asking (to my knowledge) you're gonna have to write code.

The preprocessor example I give is a clean solution re-using the Theme API (suggestions) and hooks.