I have overwritten a views field, and that is working correctly:
views-view-field--testview--page_1--testfield.html.twig
I want to pass a variable to this template but this doesn’t work:
function THEME_preprocess_views_view_field(&$variables) { $variables['test_variable'] = ("Foo"); }
If I put {{ test_variable }}
in the template, it is empty.
I also tried other preprocess variations, but nothing is passing the variable to the overwritten field template:
function THEME_preprocess_views_view/preprocess_field/etc.(&$variables) { $variables['test_variable'] = ("Foo"); }
I also did a {{ drupal_dump() }}
in my field template to check the used hook function. It says: views_view_field__testview__page_1__testfield
But this still doesn’t work: THEME_preprocess_views_view_field__testview__page_1__testfield
How can I pass the variable to this twig field template?