I've a view having two (separate) contextual filters, say node id and taxonomy id. We can pass separate contextual filter values with a "/". example: 12,13,14/8,9 as URL arguments.

But how can we get the view results by passing the dynamic contextual filter values to the view?


Here we go.

 $nodes_str = implode(',', $nids); // $nids is an dynamic array.
 $args[] = $nodes_str; // First contextual filter argument. 12,13,14.. etc
 $args[] = $tag; // Second contextual filter arguments 8,9.. etc
 $view = views_get_view('view_machine_name');
 $result = $view->execute();
 $output = $view->result;

If need futher details of the view parameters. You can debug the values using the hook_views_pre_view()

function YOUR_MODULE_views_pre_view(&$view, &$display_id, &$args) {


Hope this helps someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.