1

I created custom module with Views style plugin, there I have some fields to configure this style and in separate inc file I have preprocess to store these settings and use values in Twig template file, so I have this:

<?php

/**
 * @file
 * Theme for Example views.
 */
function template_preprocess_views_view_example(&$variables) {
  // View options set by user.
  $options = $variables['view']->style_plugin->options;

  // Update options for twig.
  $variables['options'] = $options;
}

In templates folder I have views-view-example.html.twig file and everything is working very well.

Now, I want to wrap each result from Views (row) and need to create template file for this. At the moment I don't see any wrapper there, just fields directly.

Seems like I need to define my template file to override default views-view-fields.html.twig template file.

How I can do that in my module? Do you have some example of it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.