1

Is there a way to get a field from the view in the hook_preprocess_views_view_unformatted(&$variables)?

$rows = $variables['rows'];
foreach ($rows as $id => $row) {
   // $row['field_name'] or something?
}
2

You find the field handlers you have configured in the Fields list in $view->field. A field handler has methods like getValue(), render() and advancedRender(), which accept as argument the row variable:

Example:

$view = $variables['view'];
$rows = $variables['rows'];
foreach ($rows as $id => $row) {
  $field_value = $view->field['field_name']->getValue($row);
}

See also Get result view with formatter programmattically

| improve this answer | |

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.