1

I'm trying to create a preprocess function to my custom view. Template is called as expected but my preprocess is called at beginning of html and left my entire page blank.

If I change to default template (views_view_unformatted.html.twig) the execution of theme_preprocess_views_view_unformatted() works as expected, right on my view is. But if change to views_view__custom.html.twig the execution of theme_preprocess_views_view__custom() occur at beginning of html!

This is the normal behavior? Or something is wrong? I just want to create my custom view template and create a preprocess function for it.

0

In Drupal 8 it is possible to have preprocess functions for the theme suggestions.

So let's say if your template for the View is views-view--test-view--block-1.html.twig, you would have following preprocess functions:

  • THEMENAME_preprocess_views_view__test_view__block_1
  • THEMENAME_preprocess_views_view__test_view
  • THEMENAME_preprocess_views_view

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.