Closed (won't fix)
Project:
Views (for Drupal 7)
Version:
6.x-2.0-rc1
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
21 Jul 2008 at 13:49 UTC
Updated:
10 Apr 2009 at 20:05 UTC
I'm trying to use views argument to add dynamically filter with the following argument validator code:
$view->display['default']->display_options['filters'] += array(
'dynamic_filter_1' => array(
'operator' => '>=',
'value' => array('value' => $argument, 'min' => '', 'max' => ''),
'group' => '0',
'exposed' => FALSE,
'expose' => array('operator' => FALSE, 'label' => ''),
'id' => 'field_diameter_value',
'table' => 'node_data_field_diameter',
'field' => 'field_diameter_value',
'relationship' => 'none'
)
);
return FALSE;
But there are many 'filters' arrays in $view and it looks like this is not the right one. Where should I add my dynamic filter? Is there something wrong with this style of adding filter?
Comments
Comment #1
merlinofchaos commentedOrdinarily, you should use $view->add_item() instead. However, if you're in argument validator code, it is probably too late to add it to the display; in which case, you need to add it directly to $view->filter array.
Comment #2
merlinofchaos commentedI realize my answer was fairly terse but I don't have a great deal more to add; let me know if you need more information (specific questions always get better answers =)
Comment #3
ogi commentedI tried with the following validation code but it didn't work. Any ideas? Is construction of filter correct? I used as a model filters constructed by Filter pane and I what I saw with Krumo. As a difference with other items in
$view->filter, I couldn't findviews_handler_filter_numeric_contentin http://views.doc.logrus.com/ and so I usedviews_handler_filter_numeric.Comment #4
merlinofchaos commentedviews_handler_filter_numeric_content is probably a CCK filter (though it is misnamed).
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #6
mpaler commentedSorry if changing this back to active is poor form however, this is exactly what I'm trying to do.
To the author -- Have you managed to work this out?
To the world, has anyone managed to add/modify a filter dynamically via argument validator code for views 2? I've found articles for views 1 but nothing definitive for views 2?
Thanks,
Mike
Comment #7
merlinofchaos commentedIn Views 2, you cannot modify filters with argument validators because filters are processed prior to arguments.