I want to embed a view in content of type basic page in D8. How to I do that. Insert View module is still not stable to be used in D8.
-
There are many ways of doing this, often using contrib modules that don't have stable releases. You need to tell us more about the relationship you want between the content and the view. Is the view always identical? Is it the same view, but filtered by a property of the content? Or do you want editors to be able to select a different view on each entity?– JonathanSep 20, 2016 at 11:05
2 Answers
You might want to have a look at Paragraphs and some of the new Views Reference fields. You could then intersperse Views and content.
You can use views_embed_view() function
\Drupal::service('renderer')->render(views_embed_view('VIEW_NAME'));
Where VIEW_NAME is the name of your view.
-
This isn't very ideal unless you're hardcoding placement in templates.– KevinSep 19, 2016 at 10:17
-
The optional second parameter to views_embed_view will let you set the display name. Sep 23, 2016 at 15:24