I'm currently trying to output views referenced in a node (with Views Reference Field) inside page.html.twig
Twig template.
I know I can just add or embed a view using {{ drupal_view('machine_name', 'block_1') }}
(with Twig Tweak) in my Twig template. But I want the editors to have the flexibility to add or change views in the node and have them printed without writing code.
I can't seem to find any documentation on how to output a referenced view to my Twig template.
{{ content.field_your_views_reference_field }}
. If you want to change the output of the view, use the views template suggestions.node.field_view_works.title
but it outputs a numerical value1
{{ node.field_myfield.fieldDefinition.label }}
. For nested field values from inside your view, you must use the proper view templates, you can't easily access them in page or node.views-view-list.html.twig
How can I call the template within mypage.html.twig
?{{ content }}
. I'd suggest to take a look at core themestable
and look forview-*.html.twig
there to find out which variables are available in those files. Remember there a different view types, this tutorial has a good overview which view uses which file names.