Extra quick tip for developers working with Drupal 8 or 9: Adding views to your page content is now incredibly straightforward:
$content['editor_tools']['view'] = [
'#type' => 'view',
'#name' => 'editor_tools',
'#display_id' => 'embed',
'#arguments' => [
123,
],
];
And that's it! $content
is my render array which I'll return and let Drupal render. I suspect most of the bits there are self-explanatory, but in case they aren't:
-
'#type' => 'view'
is the magic that lets Drupal's rendering system know that this array represents a view to render.
-
'#name'
is the machine name of the view you want...