In Drupal 8, I am trying to use hook_preprocess_views_view_fields to process certain fields of certain views. I know how to test for the field name via $variables['field']->field, but I can't find any similar way to test for the view's machine name. Is there a similar way to do it for the view?


The view itself is in the $variables array for all of the views hooks.

/** @var \Drupal\views\ViewExecutable $view */
$view = $variables['view'];

should give you what you are looking for.

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.