I have a view and I want to alter the output in each row.
So I have tried hook_views_pre_render(), and hook_preprocess_views_view(), but with no luck. In both of the above hooks I got data in $view->result
, but there seems to be no way to change the rendered output.
-
no those are not removed instead in hook_views_pre_render($view) its not referenced, but hook_preprocess_views_view(&$variables) its referenced. so the changes can take place in later like : $view = &$variables['view']; $view->element['#title']['#markup'] = 'abc';– harsh_behl_0007Apr 23, 2016 at 6:16
1 Answer
After a long a research and development, I came to an conclusion that this could be the answer:
foreach ($view->result as $result) {
$result->_entity->set('field_name', array(0 => 'value'));
}