Hi,
I am trying to display past exhibitions by year. If I create a view with a filter of exhibition finish date < now, that works correctly. If I create a view without that filter, but with an argument of year (where year is = to the exhibition start or finish year) that works correctly. But if I create a view with both the filter and argument as described, only the date filter seems to be applied:
SELECT node.nid AS nid,
node.title AS node_title,
node_data_field_exhibdates.field_exhibdates_value AS node_data_field_exhibdates_field_exhibdates_value,
node_data_field_exhibdates.field_exhibdates_value2 AS node_data_field_exhibdates_field_exhibdates_value2,
node.type AS node_type,
node.vid AS node_vid
FROM node node
LEFT JOIN content_type_exhibition node_data_field_exhibdates ON node.vid = node_data_field_exhibdates.vid
WHERE (node.type in ('exhibition'))
AND ((DATE_FORMAT(node_data_field_exhibdates.field_exhibdates_value2, '%Y-%m-%d') < '2009-06-04') OR ((DATE_FORMAT(node_data_field_exhibdates.field_exhibdates_value, '%Y') <= '2008' AND DATE_FORMAT(node_data_field_exhibdates.field_exhibdates_value2, '%Y') >= '2008')) OR ((DATE_FORMAT(node_data_field_exhibdates.field_exhibdates_value, '%Y') <= '2008' AND DATE_FORMAT(node_data_field_exhibdates.field_exhibdates_value2, '%Y') >= '2008')))
ORDER BY node_data_field_exhibdates_field_exhibdates_value DESC
Any help much appreciated. Here's the exported view:
$view = new view; $view->name = 'pastexhibitionbyyear'; $view->description = 'per year exhibition'; $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' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'link_to_node' => 1, 'exclude' => 0, 'id' => 'title', 'table' => 'node', 'field' => 'title', 'relationship' => 'none', ), 'field_exhibdates_value' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'link_to_node' => 0, 'label_type' => 'none', '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_exhibdates_value', 'table' => 'node_data_field_exhibdates', 'field' => 'field_exhibdates_value', 'relationship' => 'none', ), 'field_artists_value' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'link_to_node' => 0, 'label_type' => 'none', 'format' => 'default', 'multiple' => array( 'group' => 1, 'multiple_number' => '', 'multiple_from' => '', 'multiple_reversed' => 0, ), 'exclude' => 0, 'id' => 'field_artists_value', 'table' => 'node_data_field_artists', 'field' => 'field_artists_value', 'relationship' => 'none', ), 'field_images_fid' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'link_to_node' => 0, 'label_type' => 'none', 'format' => 'right_column200_default', 'multiple' => array( 'group' => 1, 'multiple_number' => '', 'multiple_from' => '', 'multiple_reversed' => 0, ), 'exclude' => 0, 'id' => 'field_images_fid', 'table' => 'node_data_field_images', 'field' => 'field_images_fid', 'relationship' => 'none', ), )); $handler->override_option('sorts', array( 'field_exhibdates_value' => array( 'order' => 'DESC', 'delta' => -1, 'id' => 'field_exhibdates_value', 'table' => 'node_data_field_exhibdates', 'field' => 'field_exhibdates_value', 'relationship' => 'none', ), )); $handler->override_option('arguments', array( 'date_argument' => array( 'default_action' => 'ignore', 'style_plugin' => 'default_summary', 'style_options' => array(), 'wildcard' => 'all', 'wildcard_substitution' => 'All', 'title' => '%1 Exhibitions', 'default_argument_type' => 'fixed', 'default_argument' => '', 'validate_type' => 'none', 'validate_fail' => 'not found', 'date_fields' => array( 'node_data_field_exhibdates.field_exhibdates_value' => 'node_data_field_exhibdates.field_exhibdates_value', 'node_data_field_exhibdates.field_exhibdates_value2' => 'node_data_field_exhibdates.field_exhibdates_value2', ), 'year_range' => '-10:+3', 'date_method' => 'OR', 'granularity' => 'year', 'id' => 'date_argument', 'table' => 'node', 'field' => 'date_argument', 'validate_user_argument_type' => 'uid', 'validate_user_roles' => array( '2' => 0, '3' => 0, '4' => 0, ), 'relationship' => 'none', 'default_options_div_prefix' => '', 'default_argument_user' => 0, 'default_argument_fixed' => '', 'default_argument_php' => '', 'validate_argument_node_type' => array( 'event' => 0, 'exhibition' => 0, 'page' => 0, 'story' => 0, ), 'validate_argument_node_access' => 0, 'validate_argument_nid_type' => 'nid', 'validate_argument_vocabulary' => array( '2' => 0, '1' => 0, ), 'validate_argument_type' => 'tid', 'validate_argument_transform' => 0, 'validate_user_restrict_roles' => 0, 'validate_argument_php' => '', ), )); $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', ), 'date_filter' => array( 'operator' => '<', 'value' => array( 'value' => NULL, 'min' => NULL, 'max' => NULL, 'default_date' => 'now', 'default_to_date' => '', ), 'group' => '0', 'exposed' => FALSE, 'expose' => array( 'operator' => FALSE, 'label' => '', ), 'date_fields' => array( 'node_data_field_exhibdates.field_exhibdates_value2' => 'node_data_field_exhibdates.field_exhibdates_value2', ), 'date_method' => 'OR', 'granularity' => 'day', 'form_type' => 'date_select', 'default_date' => 'now', 'default_to_date' => '', 'year_range' => '-12:+3', 'id' => 'date_filter', 'table' => 'node', 'field' => 'date_filter', 'relationship' => 'none', ), )); $handler->override_option('access', array( 'type' => 'none', )); $handler->override_option('items_per_page', 0); $handler = $view->new_display('page', 'Page', 'page_1'); $handler->override_option('path', 'exhibitions/pastexhibitionsbyyear/%'); $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
Comment #1
merlinofchaos commentedI'm not sure if this should be date.module or CCK. Trying date first.
Comment #2
merlinofchaos commentedBTW when you paste a view export, please disable any wysiwyg as it translates the code kind of badly.
Comment #3
msgreenspike commentedHi,
I had another look. I think the problem relates to AND vs. OR. In the filter, I specify AND. In the argument, I specify OR as the comparison is start_date_year = XXXX OR finish_date_year = XXXX. The resulting query specifies an OR between the filter and the argument comparisons. This seems like a bug to me...
SELECT node.nid AS nid,
node.title AS node_title,
node_data_field_exhibdates.field_exhibdates_value AS node_data_field_exhibdates_field_exhibdates_value,
node_data_field_exhibdates.field_exhibdates_value2 AS node_data_field_exhibdates_field_exhibdates_value2,
node.type AS node_type,
node.vid AS node_vid
FROM node node
LEFT JOIN content_type_exhibition node_data_field_exhibdates ON node.vid = node_data_field_exhibdates.vid
WHERE (node.type in ('exhibition'))
AND ((DATE_FORMAT(node_data_field_exhibdates.field_exhibdates_value2, '%Y-%m-%d') < '2009-06-04') OR ((DATE_FORMAT(node_data_field_exhibdates.field_exhibdates_value, '%Y') <= '2008' AND DATE_FORMAT(node_data_field_exhibdates.field_exhibdates_value2, '%Y') >= '2008')) OR ((DATE_FORMAT(node_data_field_exhibdates.field_exhibdates_value, '%Y') <= '2008' AND DATE_FORMAT(node_data_field_exhibdates.field_exhibdates_value2, '%Y') >= '2008')))
ORDER BY node_data_field_exhibdates_field_exhibdates_value DESC
here's a cleaner version of the code:
Comment #4
merlinofchaos commentedIf you know so much about what's going on that you can override the Views module author's moving this from one queue to another, then you had better know enough to fix the problem yourself.
Comment #5
msgreenspike commentedSorry, I didn't mean to offend you. Just trying to help.
Comment #6
amcc commentedI'm having a very similar problem to this:
In my case i've got events that span a number of years - I have a past events view and a future events view.
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.
In my future events view i've used the same filter and it works fine (using 'greater than' of course rather than 'less than' to get future events)
Here's my view:
Comment #7
arlinsandbulte commentedI think there has been some recent changes and fixes for dates in filters.
Try the latest releases (and -dev).
If you still have problems, please open a new issue.