Drupal 7 – Render a view with contextual filter argument programmatically

Some days ago, i write a blog post about how to render a Drupal 7 block programmatically.
Drupal 7 – Render a Block programmatically

If the block is created by Views, there is a simpler solution provided by the Views API. And we can also pass the contextual filter argument too.

print views_embed_view(<view machine name>, <display id>, <arg 1>);

 

Done =)

Reference: Outputting a Drupal 7 View programmatically with Contextual Filters (arguments)

Leave a comment

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