For my view's php field, I configured it to use my own custom PHP sorting. Here is what's in the "Click sort code" box:
if ( function_exists ( "mymodule_log_view_time_sort" ) )
mymodule_log_view_time_sort ( $view, $handler, $row1, $row2 );
From the description, it says my custom sorting function should return an integer either < 0, > 0 or = 0 which will determine whether row1 comes before, stay or after row2. But it seems no matter what my code returns, the order remains the same! I verified this with a very simple function that just return either -1, 0 or 1:
function mymodule_log_view_time_sort ( $view, $handler, $row1, $row2 )
{
return ( -1 );
}
I dug into the Views PHP module code a bit and it appears in the php_click_sort() function, the following line always have $result = 0:
$result = (int)$function($this->view, $this, $this->php_static_variable, $normalized_row1, $normalized_row2);
Either I'm doing something wrong or something is broken...any help is appreciated!
Comments
Comment #1
monaw CreditAttribution: monaw commentedOk, I've made the following changes and custom sorting appears to be working:
return ( mymodule_views_log_time_sort ( $handler, $row1, $row2 ) );
instead of justmymodule_views_log_time_sort ( $handler, $row1, $row2 );
Hope this helps someone else.