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_viewhook_views_pre_buildhook_views_post_buildhook_views_pre_executehook_views_post_executehook_views_pre_renderhook_views_post_render
I'm currently trying to alter properly the output of a view field :
I tried with hook_views_post_execute(&$view) :
function MODULE_views_post_execute(&$view) { if ($view->name == 'foo' && $view->current_display == 'bar') { foreach ($view->result as $result) { if (isset($result->field_field_status)) { switch($result->field_field_status[0]['raw']['value'] ) { case 1: $text = 'ABC'; break; case 2: $text = 'DEF'; break; //and so on } $result->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(&$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 ?