4

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_0007 Apr 23 '16 at 6:16
3

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'));
}

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.