I've got events that span a number of years - I have a past events view and a future events view:

In my future events view i've used a filter to only show events with a date 'greater than' 'now'

In the past events i'm using an argument to show the events by year - but in the current year I don't want to show events in the future.

So I have an argument that takes the year and this filters the 'from' date - this works correctly.

If I add a filter to only show events where the 'to' date is 'less than' 'now' the view then adds in the all the events in the range specified in the date filter. i.e. if the range is -3:+3 in the date filter I get all those events regardless of setting the 'to' field to 'less than' 'now'. I'm not sure if this is the reason for the problem, but whatever permutation of settings i've tried its not working correctly.

I'm using views version 6.x-2.6 for the record - If this is a views problem then i can always move this over to that queue.

Here's my view:

$view = new view;
$view->name = 'past_events';
$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', 'Defaults', 'default');
$handler->override_option('fields', array(
  'title' => array(
    'label' => 'Title',
    'link_to_node' => 0,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
  'body' => array(
    'label' => 'Body',
    'exclude' => 0,
    'id' => 'body',
    'table' => 'node_revisions',
    'field' => 'body',
    'relationship' => 'none',
  ),
  'field_exhibition_date_value' => array(
    'label' => 'Date',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_to' => '',
      'group' => TRUE,
    ),
    'repeat' => array(
      'show_repeat_rule' => '',
    ),
    'fromto' => array(
      'fromto' => 'both',
    ),
    'exclude' => 0,
    'id' => 'field_exhibition_date_value',
    'table' => 'node_data_field_exhibition_date',
    'field' => 'field_exhibition_date_value',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'field_exhibition_date_value' => array(
    'order' => 'DESC',
    'delta' => -1,
    'id' => 'field_exhibition_date_value',
    'table' => 'node_data_field_exhibition_date',
    'field' => 'field_exhibition_date_value',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
));
$handler->override_option('arguments', array(
  'date_argument' => array(
    'default_action' => 'empty',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'breadcrumb' => '',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'date_fields' => array(
      'node_data_field_exhibition_date.field_exhibition_date_value' => 'node_data_field_exhibition_date.field_exhibition_date_value',
    ),
    'year_range' => '-35:+3',
    'date_method' => 'OR',
    'granularity' => 'year',
    'id' => 'date_argument',
    'table' => 'node',
    'field' => 'date_argument',
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'artwork' => 0,
      'exhibition' => 0,
      'music' => 0,
      'page' => 0,
      'text' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
      '3' => 0,
      '4' => 0,
      '5' => 0,
      '7' => 0,
      '6' => 0,
    ),
    'validate_argument_type' => 'tid',
    'user_argument_type' => '',
    'restrict_user_roles' => 0,
    'user_roles' => array(),
    'validate_argument_php' => 'field_exhibition_date',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
      '3' => 0,
    ),
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'exhibition' => 'exhibition',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
  'status' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'relationship' => 'none',
  ),
  'date_filter' => array(
    'operator' => '<',
    'value' => array(
      'min' => NULL,
      'max' => NULL,
      'value' => NULL,
      'default_date' => 'now',
      'default_to_date' => '',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'date_fields' => array(
      'node_data_field_exhibition_date.field_exhibition_date_value' => 'node_data_field_exhibition_date.field_exhibition_date_value',
    ),
    'date_method' => 'OR',
    'granularity' => 'day',
    'form_type' => 'date_select',
    'default_date' => 'now',
    'default_to_date' => '',
    'year_range' => '-3:+3',
    'id' => 'date_filter',
    'table' => 'node',
    'field' => 'date_filter',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'past_events');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));

Comments

ajspadial’s picture

Hello,

I've found also same bug.

I will tell how I have surpassed it.

1. I quit the date field filter.
2. I put a new filter on Node:published

Then I needed a way to unpublish nodes when its date passed. I use Views Bulk Operations that apply Actions to the results of a View, and Job Queue that calls this View via cron.

Hope this be useful. If you need more details, please ask.

Marc_PCR’s picture

Hi, I have exactly the same problem.I want to make a view of past events.

I give to my view an argument (the year). Everything is ok.

For the current year, I want to hide the upcoming events, so I add a filter date

The solution of tonisan isn't good for me since nobody will be available to unpublish the event each time. Somebody have a solution?

Cheers

origaman’s picture

Same problem here: Year as argument; Filter "up to now" => View shows all nodes up to now, even the ones from years before the passed year argument.

Date 6.x-2.4
Views 6.x-2.6

bmcmurray’s picture

I don't know if anyone else is still tracking this but I ran into the same problem.

It appears, however, that if you set the Method ('date_method') to "AND" instead of "OR" in both the argument and the filter, that both will be respected.

Hope this helps someone else.

ecksley’s picture

Same problem? I had it set up and working months ago, and now it doesn't anymore. I suspect it was a recent update to Date or Views that changed things?

----------------------------

Update:

I got it working again, but had to set up my View differently.
1.) My argument changed from Date (users) to Date (node)
2.) In the argument setup under "Date field(s): " I selected "Content: Date (field_news_datestamp<-- the name of my field) "

Now it works like a charm. :)

amcc’s picture

Status: Active » Fixed

it appears that this comment #4 (http://drupal.org/user/66162) solves the problem.

i.e. make sure you sent your argument and filter to AND and they should then work in conjunction and give you the correct result

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.