Independent multiple contextual filters

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
nithinkolekar's picture

I was looking for solution for, how to configure multiple contextual filters and always found links which is either having
1. contextual filter which support multiple values
2. more than one contextual filter configured - To allow filtering current viewing node in related block using exclude checkbox.

Before describing my use case, I need some clarification about contextual filter.
1. Is there any limitation on contextual filter per views ie how many contextual filters we can have.
2. Why isn't there any global options for views to configure like all contextual filter should be present or any one (just like panel's selection rules) or just make any filter optional.

use case:
Lets say I need a view with
Relationships :
Entity Reference: Actors

Two contextual filter
1) (Content entity referenced from field_actors_in_movie) Content: Nid
--When the filter value is NOT available
---Provide default value

$nid = arg(1);//will change for autocomplete path
$node = node_load($nid);
$view_par = array();
    if($node && isset($node->field_er_parameters)) {
      $related = field_get_items('node', $node, 'field_er_parameters');
for($i=0; $i<count($related);$i++) {
         $view_par[] = $related[$i]['target_id'];
}
return implode(',', $view_par);
}
else{
return 0;
}

Specify validation criteria
--content
---Filter value format
-----Node Id
---Action to take if filter value does not validate
----Display all results of specified field

2) Content: Release Year (field_release_year)
--When the filter value is NOT available
---Provide default value

$nid = arg(2);//will change for autocomplete path
$node = node_load($nid);
//dpm($nid);dpm($node);
$view_par = array();
if($node && isset($node->field_parameter_year)) {
      $related = field_get_items('node', $node, 'field_parameter_year');
      foreach($related as $tag) {
          $view_par[] = $tag['tid'];
          //dpm($tag);
      }//dpm(implode(',', $view_par));
return implode(',', $view_par);
}
else{
return 'all';
}

Specify validation criteria
--taxonomy term
---Filter value type
-----term Id
---Action to take if filter value does not validate
----Display all results of specified field

Passing Parameter
As we are configured views to provide default value using php code , NID is passed using custom path.
Case 1.
When node contains
ER field parameter : Johnny Depp
Year Parameter: 2014
Should return all movie list acted by Johnny depp and released in the year 2014.

Case 2.
When node contains
ER field parameter : Johnny Depp
Year Parameter: left empty
Should return all movie list acted by Johnny Depp regardless of release year.

Case 3.
When node contains
ER field parameter : left empty
Year Parameter: 2014
Should return all movie list released year.(Obviously total items is configured in pager setting)

Is it possible to have single view for this purpose?
Could optional filter feature be implemented in views?
Any contrib module already present which provides this functionality?(couldn't find it in DO or SO)
This is doable, but something missing in configuration?