We have a custom block type block_countries and we are using a View(my_view_custom) to display the all the blocks where type = block_countries. Under block_countries view mode, we setup a "Full" view mode where we display certain information.

The view is displayed as a block and placed into a region (i.e. content region) from the theme. We want to style the block_countries "Full" view mode and setup a preprocess hook to do some processing, however we cannot find the way to do this.

We need help figuring out the proper twig template and preprocess_hook to call in order to get the desired out below. How can we do this?

Block type fields (block_countries):

  1. body
  2. language
  3. country (Entity reference: taxonomy term)

Full view mode (fields shown):

  1. body
  2. country

View settings:

  1. Format = unformatted list
  2. show: custom block: Full (where full is the view mode)
  3. Filter Criteria: custom block : block type = block_countries

We have tried the following but they do not work





Desired output (per row returned from view):

<div data-country="{{ country }}"> {{ body }} </div>

1 Answer 1


Don't use custom blocks, use nodes or a custom entity type. Custom blocks are designed to be displayed as a block, not a view inside a block. They don't have a template on their own. See https://www.drupal.org/node/2704331.

Yes, it's not great, but it is unlikely that this will change any time soon.

  • thinking about this, i should have explored the custom entity type sooner. I ended up finding the correct view preprocess to get what i needed, thanks. Jan 30, 2018 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.