In some cases you want to embed a view inside your custom module. The views_embed_view() function is the way to go. With this little snippet, you can render any view:

$result = render(views_embed_view('submenu', 'block_1'));
print $result;

In this case, "submenu" is the name of my view and "block_1" is the display id. For more examples, take a look at the function page.

update: 06/19/2019

It is also possible to load your view programmatically and display it in twig:



Saved you some valuable time?

Received 100 so far from 4 kind contributors.