I tried to add a new filter to my simple view with just a row of code for the PHP filter: return true;
. I expect to have 0 rows as result, instead of I receive all nodes.
$view = new view;
$view->name = 'trial';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Predefinite', 'default');
$handler->override_option('fields', array(
'title' => array(
'id' => 'title',
'table' => 'node',
'field' => 'title',
),
));
$handler->override_option('filters', array(
'php' => array(
'operator' => '=',
'value' => '',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'use_php_setup' => 0,
'php_setup' => '',
'php_filter' => 'return true;',
'id' => 'php',
'table' => 'views',
'field' => 'php',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
Comments
Comment #1
infojunkieIf I add a page display to your view, I receive no rows on the page. What was your precise usage scenario?
Comment #2
infojunkieComment #3
infojunkieOr are you referring to the pager not being updated? Ref: #1129528: Pager isn't updated based on filtering code. If so, please close this as duplicate.
Comment #4
infojunkieAlso, you should be using Views 6.x-2.x-dev, not Views 6.x-2.12.
Comment #5
GiorgosK#4 perhaps a compatibility message on the project page would be useful to many users trying out the module (I too was confused since the project page mentions "The D6 version supports both Views 2 and Views 3." but with no specific versions)
Comment #6
Chemtox CreditAttribution: Chemtox commentedHmm, where would we find Views 6.x-2.x-dev? There's no dev release for Views 2 in its page: http://drupal.org/node/38878/release?api_version[]=87
But I found that Views PHP is broken in Views 6.x-2.12 since it lacks hooks_views_post_execute(). Seems you also stumbled onto this, fairsayan, though merlin's answer was that it is supported. Is there a hidden release, or are you all actually thinking about Views 3?
Comment #7
GiorgosKtry 3.x version of views I think it works
Comment #8
infojunkieUpdated the module documentation to explicitly mention the latest D6/Views 2 release and point to it as well.
Comment #10
ahtih CreditAttribution: ahtih commentedFYI; I don't see the Views 2 development version mentioned in module documentation (I am assuming you mean the http://drupal.org/project/views_php page as it is the only documentation I found). The page just says "The D6 version supports both Views 2 and Views 3" which surely causes confusion, as it clearly does not work with current recommended 6.x Views version (6.x-2.12).
Comment #11
Chemtox CreditAttribution: Chemtox commentedahtih,
Views 6.x-2.x-dev is not on the project page for some reason, but buried at the very end of View's release list, for which I myself provided a link on my previous post --where I somehow was blind to the pager buttons, so I couldn't find it either as it's on the second page. :-P
Here's a direct link: http://drupal.org/node/95897
Reopening as infojunkie's clarifications seem to have been reverted.
Comment #12
Liam MorlandDrupal 6 is no longer supported. If this applies to a later version, please re-open and update the version.