I used this topic before asking question but even if the problem is very very closed, the answers given did not work for me.
So I need to alter the query of one of my views in drupal 7. I created a new module called for example 'mymodule'. This module contains
- .info file.
- .module file.
- .views.inc file.
My .module file contains the following. Note that my .views.inc file is located at the root of the module directory. I also checked that my views api version is 3 :
function modulename_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'modulename'),
);
}
My .views.inc file, which is at the root of the module directory contains the following :
function modulename_views_query_alter(&$view, &$query) {
dpm($view);
watchdog('error title', 'error message');
echo 'TEST TEST';
die('test');
if ($view->name == 'my_view_name' && $view->current_display == 'my_display_name') {
unset($query->where[1]['conditions'][0]);
unset($query->where[1]['conditions'][1]);
}
}
I can't see what I am missing trying to implement this hook but it never go into the views_query_alter function (I cleared the cache before trying). I think I've followed all advices given in the link provided above.
Any help would be appreciated.