Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.6
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Sep 2009 at 09:58 UTC
Updated:
12 Oct 2009 at 17:40 UTC
I'm trying to add filters dynamically in hook_views_pre_build.
<?php
$options = array(
'value' => $tids,
'operator' => 'or',
'group' => 0,
'exposed' => FALSE,
'type' => 'textfield',
'limit' => TRUE,
'vid' => $voc,
'hierarchy' => 0,
'relationship' => 'node',
'reduce_duplicates' => 0,
);
$view->add_item($view->current_display, 'filter', 'term_node', 'tid', $options);
?>But views doesn't use this filter. I guess its just a little step.
Comments
Comment #1
merlinofchaos commentedHandlers are already instantiated at that point, so doing $view->add_item() won't work.
Either use hook_views_pre_view() or instantiate the handler after adding it and add directly to $view->filter[] array. The latter may actually be kind of difficult because handler instantiations are cached so the hook_views_pre_view() option may be better.