Views of content is having two contextual filter. For some reason node object is available to views so it is passing through url's 7th argument.
1.Content: Has taxonomy term ID Configuration: Php Code
$nid = arg(7);
$node = node_load($nid);
if($node && isset($node->field_tags)) {
$related = field_get_items('node', $node, 'field_tags');//dpm($related);
foreach($related as $tag) {
$view_par[] = $tag['tid'];
//dpm($tag);
}
return implode(',', $view_par);
}
else{
return 0;
}
2.Content: Nid (Ref: entity-reference-and-nested-arguments-in-views)
$nid = arg(7);
$node = node_load($nid);
$Related_ids = array ();
$Related = field_get_items ('node', $node, 'field_some_er') // Get the entity reference scope
if ($related && is_array ($related) && sizeof ($related)> 0) {
for ($i = 0; $i <count ($related); $i++) {
$ Related_ids [] = $related[$ i]['target_id'];
}
}
return implode ('+', $related_ids) // It returns the values of the field entity reference
Relationships:
Content: Taxonomy terms on node (Require this relationship :TRUE)
Content entity referenced from field_er_in_content (Require this relationship :TRUE)
With above configuration/modifying how to retrieve views's data only when
1. Any one of the filter should be present i.e either field_tags(term reference field) or field_some_er (entityreference field)
2. Both filter could be present.
but should not retrieve when both value is absent. Is there something can be done using common variable like found flag that can be shared to both php code and break the view operation.