I want to alter a query for sorting a field. I read the documentation, it says
This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. MODULENAME.views.inc must be in the directory specified by the 'path' key returned by MODULENAME_views_api(), or the same directory as the .module file, if 'path' is unspecified.
I used to implement all hooks inside my sites/default/realia/template.php so I first went stright and implemented the hook in sites/default/realaia/template.php which obviously didnt work.
function realia_views_query_alter(&$view, &$query) {
print "<h1>I am in alter query</h1>";
var_dump($query);
}
After reading doc carefully which says the hook needs to be placed inside the specific file and in a specific place I totally feel lost. Because I don't see any .module file in my sites/default/themes/realia. This is where my all files provided by realia (3rd party) are placed there is only .info file but no .module file.
There are also other related modules inside sites/all/modules/realia but looks like this folder is not a module itself becuse there are no .info or .module files inside the root but subfolders/modules has it. I went and created a file reala_submodule.views.inc with the implementation and placed one in each of the modules but I still dont see it really got executed ever.
Of course I did drush cc all every time whenever I doubted there could be caching issue. I will have followup questions related sorting once I get this implementation working. Please help.
Update:
I have created a new module called tdyards with proper steps given in the developing modules. Since I don't need anything to do other than implementing the alter query hook, I just created .info and .module and implemented hook_help. I checked my module is listed and the help also is showing my module and created the tdyards.views.inc and placed in my module root directory but again it doesnt appear its ever called.
file which made my module appear in the list and I enabled it and checked my module
tdyards.views.inc code:
<?php
function tdyards_views_query_alter(&$view, &$query) {
print "<h1>I am in tdyards alter query</h1>";
var_dump($query);
die();
}