Drupal - How to alter single custom field value in views?

function hook_views_pre_render(&$view) {

  switch ($view->name) {
    case 'YOUR_VIEW_NAME':
      //  override the global custom text field value
      $view->field['nothing']->options['alter']['text'] = 'My custom text';
    break;
  }
}

Check the link for more details How to insert values into Global custom text field of views programmatically?

add nid as field in view and use that field for condition you can add condition as follows: if ($nid == '124') { $view->field['nothing']->options['alter']['text'] = $nid}

Simple way is to create a new field field_waga which will have field_waga_1 as new name if you check in the view and then you can change the label and override that field with your custom value

if($view->result[0]->field_waga[0]['raw']['value'] == '10') {
//here you can create the field to act as custom text field and enter the custom //value
$view->result[0]->field_waga_1[0]['#markup'] = 'alter';
}

Tags:

Views

7