I am using hook_views_query_filter to append my own where clause condition with the where clause of the query generated by the view.
So for this I am using this hook.
Here is my code
function mymodule_views_query_filter(&$view, $query) {
if($view->name = "myview") {
$query->where[1] = array(
'clauses' => array(
'0'=>"field_test_value=0",
),
'args' => array('0' => 'test1', '1' => 'test2'),
'type' => 'OR',
);
}
print_r($query);
}
So the where clause becomes like this after print_r() funtion.
[where] => Array
(
[0] => Array
(
[clauses] => Array
(
[0] => node.type in ('%s')
[1] => node.status <> 0
[2] => term_data.name = '%s'
[3] => term_data_term_node__term_data.name = '%s'
)
[args] => Array
(
[0] => test1
[1] => test2l
[2] => test3
)
[type] => AND
)
[1] => Array
(
[clauses] => Array
(
[0] => field_test_value=0
)
[args] => Array
(
[0] => test1
[1] => test2
)
[type] => OR
)
)
Where the 0 index of the where clause is coming from the view query and the 1 index of the where is clause is coming from my code. But it only executes the 1 index of the where clause and display the results only if Where field_test_value=1 and I want something like this.
Where (node.type in ('%s') AND node.status <> 0 AND term_data.name = '%s' AND term_data_term_node__term_data.name = '%s') OR field_test_value=0