Alter a view. Edit view result programmatically

Submitted by editor on Fri, 09/30/2016 - 11:16
Question

How to Edit a view result programmatically ?

Example:

function MYMODULE_views_pre_render(&$view) {
  if ($view->name == 'view_myviewname') {
    $result = $view->result;
    foreach ($result as $i => $row) {

      $view->result[$i]->field_field_myfieldtext[0]['rendered']['#markup'] = "The new text";
    }
  }
}

Comments

hess (not verified)

Tue, 10/18/2016 - 13:31

How can i edit a view? I mean where should i add this program? I am really new to D8. trying to learn it.

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.