How to choose between all the Views hooks Reading the docs about Views hooks doesn't really help me to make the right choice between all the hooks. As per this comment, this is the Views hooks execution order:


hook_views_pre_view 
hook_views_pre_build 
hook_views_post_build
hook_views_pre_execute 
hook_views_post_execute 
hook_views_pre_render
hook_views_post_render


I'm currently trying to alter properly the output of a view field : 

I tried with hook_views_post_execute(&amp;$view) :

function MODULE_views_post_execute(&amp;$view) {
  if ($view-&gt;name == 'foo' &amp;&amp; $view-&gt;current_display == 'bar') {

    foreach ($view-&gt;result as $result) {

      if (isset($result-&gt;field_field_status)) {

        switch($result-&gt;field_field_status[0]['raw']['value'] ) {
          case 1: 
            $text = 'ABC';
            break;
          case 2: 
            $text = 'DEF';
            break;
          //and so on
        }  
        $result-&gt;field_field_status[0]['rendered']['#markup'] = $text;
      }
    }   
  }
}


This worked fine at first glance : returned string display nice,  but raw data were displayed again after a while. After clearing page cache the expected output turns back, but then disappeared again, and so on.

Then I tried with hook_views_pre_render(&amp;$view) , with exactly the same code inside that other hook giving exactly the same result.

Question(s) :

What makes the hook be applied or not ? Wrong hook use maybe ?  Is there any logic to apply one or another of these hooks ? (After reading @Alexar comments : yes I'd explicitly like to know about views hooks, the example is just to illustrate my searches and misunderstandings.)

I really need to understand the logic behind all that for my "learning curve".

Edit :

Lastly, I used a views-view-field.tpl.php to change the output of my field, another possibility adding more confusion to my global understanding of the view construction background... Anybody for a bit of Drupal pedagogy ?
The documentation View Hooks is clear about the purpose of every hook. It says about hook_views_post_execute(&amp;$view):


  This hook is called right after the execute process. The query has
  been executed, but the pre_render() phase has not yet happened for
  handlers.


And gives an example what you can do with this hook:

function hook_views_post_execute(&amp;$view) {
  // If there are more than 100 results, show a message that encourages the user
  // to change the filter settings.
  // (This action could be performed later in the execution process, but not
  // earlier.)
  if ($view-&gt;total_rows &gt; 100) {
    drupal_set_message(t('You have more than 100 hits. Use the filter settings to narrow down your list.'));
  }
}


At this point the database query was executed and you can do something with the result of the query, for example place this warning.

When you search in drupalcontrib, you find, that it is only used once:

drupal contrib search

Here it is used following the documentation. But no one in contrib used it for other things. You would be the first, with unpredictable results.

What you want to do is not specific to views, and because of that it is not in your list of view hooks. It is more connected to theming in drupal.

It is not advisable to put extensive code in the templates *.tpl.php, better put it into a preprocess function. Some examples for views:


hook_preprocess_views_view 
hook_preprocess_views_view_field
hook_preprocess_views_view_fields 
hook_preprocess_views_view_grid
hook_preprocess_views_view_table
hook_preprocess_views_view_unformatted
hook_preprocess_views_view_list


Use the preprocess hook, that correspondents with your views configuration.