0

I am writing a view code for my module, stuck with writing 2 filters for a single field.

 $data['taguser']['tag_uid'] = array(
    'title' => t('Tagged user'),
    'field' => array(
      'handler' => 'taguser_views_handler_field_user_name',
      'help' => t('Display the user name the Item has been assigned to.'),
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'taguser_views_handler_filter_user_options',
      'help' => t('Filter Action Items by the assigned user.'),
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_user_uid',
      'help' => t('Filter Acton Item by the assigned user.'),
    ),
    'relationship' => array(
      'help' => t('Relate a case to the user who have been assigned to the case.'),
      'handler' => 'views_handler_relationship',
      'base' => 'users',
      'base field' => 'uid',
      'label' => t('Assigned to'),
    ),
  );

i want another filter for this field like

'filter' => array(
  'handler' => 'taguser_views_handler_filter_user_options_list',
  'help' => t('Only limited user.'),
),

how can i add to it ??

0

It depends on your version of views, best way is to create the view in views and then export it, you can then tweak the code as needed.

Here is an example if you had a Node Type Filter and a Date Filter

/* Filter: Node: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'rfp' => 'rfp',
);
/* Filter: Date: Date (node) */
$handler->display->display_options['filters']['date_filter']['id'] = 'date_filter';
$handler->display->display_options['filters']['date_filter']['table'] = 'node';
$handler->display->display_options['filters']['date_filter']['field'] = 'date_filter';
$handler->display->display_options['filters']['date_filter']['operator'] = '>=';
$handler->display->display_options['filters']['date_filter']['value']['min'] = '2012-01-01 00:00:00';
$handler->display->display_options['filters']['date_filter']['value']['max'] = '2012-01-01 00:00:00';
$handler->display->display_options['filters']['date_filter']['exposed'] = TRUE;
$handler->display->display_options['filters']['date_filter']['expose']['operator'] = 'date_filter_op';
$handler->display->display_options['filters']['date_filter']['expose']['label'] = 'Date: Date (node)';
$handler->display->display_options['filters']['date_filter']['expose']['identifier'] = 'date_filter';
$handler->display->display_options['filters']['date_filter']['expose']['single'] = TRUE;
$handler->display->display_options['filters']['date_filter']['date_fields'] = array(
  'node.changed' => 'node.changed',
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.