Embedding Blocks and Views into Drupal content

Often the need arises to mix a custom block or view into the body of a Drupal node. Drupal easily allows for embedding blocks and views into defined regions, but not within content unless you use a custom token. Here's how to do that.

How do I embed a block into the body of a Drupal node?

Inside the body of your node add a token with the following format where you want the block to appear:

[[block|BLOCK ID]]

For example

[[block|dataspacecalendar]]

How do I find the block id?

Navigate to the block layout page and find your block. Click configure. Next to the Title field is the machine name of the block. That is the block id.

If there is no machine name the block is probably a view. In that case either use the view embed method or get the block id from the url. For example in a URL the block id is the last uri. https://www.lib.ncsu.edu/admin/structure/block/manage/[BLOCK ID]

How do I embed a view into the body of a Drupal node?

Inside the body of your node you will add a token with the following format where you want the view to appear. It takes two variables:

[[view|VIEW ID|DISPLAY ID]]

For example

[[view|spaces|block_1]]

How do I find the view id and display id?

Navigate to the view edit page for your view block. Either by clicking the "edit view" link from the view block or by choosing it from Structure > Views. The view id and display id will be in the URL of the view block edit page (ex: https://www.lib.ncsu.edu/admin/structure/views/view/[VIEW ID]/edit/[DISPLAY ID]).

Updated