I want to embed a view into the body of a node on Drupal 7. I've tried the module Insert View and that didn't work.
I also saw support from Drupal on inputting PHP code, but I have no idea where to put that code.
I want to embed a view into the body of a node on Drupal 7. I've tried the module Insert View and that didn't work.
I also saw support from Drupal on inputting PHP code, but I have no idea where to put that code.
The best solution I've found so far is the Insert View module. It allows you to use tokens in the textarea to insert views wherever you'd like.
The UX of having to write out the token may be the biggest downside. I'd personally like to see a WYSIWYG button created to make use of this (similar to Token Insert Entity), but it's not too tricky to educate users how to use it by typing the token.
Other negatives could be potential performance and security concerns. As it says in the README.txt:
SECURITY WARNING
This filter is powerful, therefore it should be granted to trusted users only. If you allow this filter to untrusted users, then you have to make sure that EVERY VIEW EVERY DISPLAY (default display also!) has correct views access settings.
PERFORMANCE
To display views correctly, Insert view turns off caching for the input formats for which it is enabled. That means every node using this input format will not be cacheable. This can impact site performance. In these cases, it is recommended to create a special input format for use when inserting views.
When I want to display a View on certain content types, I make use of the functionality offered by the EVA: Entity Views Attachment module. On the entity's Field Display administration page, you can (like any other field) set the order for outputting the Views' result.
An interesting feature of the EVA: Entity Views Attachment module is that it allows to pass any token generated from the specific entity to the View as an argument.
You can use views_embed_views().
<?php
print views_embed_view('view-name', 'display-name','arguments');
?>
Put that in your page.tpl.php or other relevant template file in your theme. Use Devel to find out which template the page is using if needed.
Or you can use the block display on the view and assign your block to the main content region as well.
There are several ways to accomplish this task. I recommend checking out the doc link above and reading the comments for other ways as well.