Drupal – Render a View in PHP Code

We can render a block in PHP as we discussed previously.
Drupal – Render a Block in PHP Code

This time, we want to render a view display by using the views_embed_view().

<?php print views_embed_view('<view name>', '<display id>', <argument>); ?>


In the above example, <view name> and <argument> are straight forward but for <display id>, you need to some tricky steps to figure it out.

First, go to the Views UI of the specific view and select the display which you want to embed. Then mouse hover on any items in Basic settings.


The <display id> is highlighted in red above.

Done =)



2 thoughts on “Drupal – Render a View in PHP Code”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.