Nuxtstop

For all things nuxt.js

Multiple Views in One Block / Drupal 8

10 0

Install module Snippet manager:

composer require drupal/snippet_manager
Enter fullscreen mode Exit fullscreen mode

Enable module Snippet manager:

drush en snippet_manager -y
Enter fullscreen mode Exit fullscreen mode

Go to Structure → Snippets and add a new one:

/admin/structure/snippet/add
Enter fullscreen mode Exit fullscreen mode

Image description

Go to the Templates tab and Add Variable.

Image description

From the list, choose the desired view.

Image description

And here we have a snippet, which will display a block presentation with articles.

Image description

Similarly, we add more performances there, and not only that.

Image description

Go to page Block Diagram:

/admin/structure/block
Enter fullscreen mode Exit fullscreen mode

And place our snippet block.

Image description

Let's see the result.

Image description

This is the easiest and most convenient way to display not only views but also blocks, menus, forms and so on in one place.

Module page: https://www.drupal.org/project/snippet_manager

Author: https://www.drupal.org/u/chi

Why not create a new region and put 2 blocks of Views there?

That would be very inconvenient to maintain. If you need to move the Views just above or below where they are, you'll have to move the region in the theme settings, not the block in the block scheme. 

And allocating a separate region for one block doesn't seem like the best solution.

Why not create a separate block type and display views through the Views Reference module?

A block placed this way will be a content block, which means that if you create it on your local/technical server, you can't transfer it without a DB, because it won't get into configs.

Why not create a separate block type and output views through the Twig Tweak module?

Similarly to the point above - such a block can't be transferred without DB.

Exception: if you make a block through Block Plugin.

Also twig can be used in Snippet Manager blocks that go into configs.