How to insert Views Block inside a Drupal node

Submitted by ravisagar on Sat, 05/23/2015 - 12:20
If you ask any Drupal developer and site builder to list their top favorite module then I am sure Views will be surely in their list. It is such an amazing module that I don't think any site is built without using this module and it should probably be listed in Drupal hall of fame of modules. This post is not entirely about Views module but rather a small use case that I wanted to discuss with others. Using views people usually create a Durpal block, page or feed. A Drupal block is quite useful because you can display a block which displays small piece of information any any location in your site. The information displayed in a Block could be static and if you used views then probably you want to display something dynamic. Something like top 5 popular blogs on the site, recently added comments or may be upcoming events. Usually the blocks are added in the regions provided by your theme but there could be a scenario when you want to insert a block which is generated through a view inside a node. It could be a page or a blog. For instance we recently create a separate page on this site for showcasing Atlassian related work that we do. Now if you open this page you would notice that this page only has the information related to Atlassian, be it the slider or client's logo. On this page there is a block called "Our recent blogs on Atlassian tools" that displays the list of blogs published on our site which are tagged with Atlassian taxonomy term. Now this is actually a block and we wanted to display it right inside the node. On this page we are actually using an Omega layout without any sidebar and we didn't want to spend time creating a new layout for this page. Our only intention was to insert this block inside node so it people can see our recent Atlassian related blogs when they are reading information related to our offerings.

Download Insert View module

There is an amazing module that lets you insert a Block generated through a View inside a node. The name of the module is Insert View and this is the link to download it https://www.drupal.org/project/insert_view

Enable it in the text format input filter

This module will simply provide you an option to use a format in the body of the node that will be replaced by the Block View you refer using its ID. Go to your Text formats and enable "Insert view filter".

Use the following format inside the node

[view:name=display=args] If you don't have any argument then use like this. [view:views_blog=block_1] In this case the name of the View we want to refer to is views_blog and the display id is block_1. I hope you get the idea now, pretty simple but really useful in such cases.