[SOLVED] [Drupal Views] How to pass contextual filters to a View embedded in a node?

| | 1 min read

Drupal Views can be displayed as both blocks and pages. If you want the View to be embedded in a node in your Drupal site then the obvious choice would be to display it as a block. View blocks can be embedded in a node as any other block by calling a set of functions like block_load and drupal_render. However it is not directly possible to pass contextual filters as arguments to those functions if your View uses them. Read on to find out how to pass contextual filters to a View embedded in a node.

If you are using the block_load function then you would need to pass the values of the contextual filters in $_GET as it is a global variable which represents the query strings and Views will be able to access it. However this task can be taken over by the Drupal EVA module. If you use this module you do not need to use PHP to embed the View in the node and it has built in support for contextual filters.

Hope that helps.

The easiest way to solve a Drupal issue is to hand it to the Drupal experts. We can provide a wide range of Drupal services to help you maintain and manage your Drupal websites.Get in touch with us to know more.