My requirement is to sort the nodes with a "condition" based on whether a field called myfield has value in it or not and then by date created. That means, show nodes first if a field has value and then by datecreated.
its something like this sql query
select field1,
datecreated,
if(isnull(myfield,1),1,0) hasvalue
from table
order by hasvalue asc, datecreated desc
For doing this I learnt that I need to create a module called tdyards and implemented tdyards_views_query_alter in tdyards.views.inc with this code in it and enabled the module.
<?php
function tdyards_views_query_alter(&$view, &$query) {
print "<h1>I am in tdyards alter query</h1>";
var_dump($query);
die();
}
I was expecting this pileup my screen with the dump but it seems like it is never called this function. Am I missing anything else here? If my guess is correct Iit must call this for each and every view because my implementation doesn not have any condition