Changing view field value programmatically

Public

Sometimes you need to change the value of the view field in views. This snippet shows one of approaches how you can achieve that.

Get raw version
php
  1. function hook_views_pre_render(&$view){
  2. foreach($view->result as $r => &$result) {
  3. if (isset($result->field_field_name[0]['rendered']['#markup'])){
  4. $result->field_field_name[0]['rendered']['#markup'] = "Your value goes here";
  5. }
  6. }
  7. }

Comments