Closed (fixed)
Project:
Views (for Drupal 7)
Version:
5.x-1.6
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
29 Aug 2007 at 14:29 UTC
Updated:
5 Oct 2008 at 20:25 UTC
On line 1696 of views.module, I found this code:
case 'month':
$field = "DATE_FORMAT(FROM_UNIXTIME($sortinfo[table].$sortinfo[field]), '%Y%m%)";
break;
The middle line needs is missing an ' and probably does not need that %. Loading the view gave me a database error when trying to render. I took my hand at fixing this and ended up with the code below and it seemed to display correctly:
case 'month':
$field = "DATE_FORMAT(FROM_UNIXTIME($sortinfo[table].$sortinfo[field]), '%Y%m')";
break;
Thanks,
Dan Ficker
P.S. - For any reason you may have, I have also exported the view I was using:
$view = new stdClass();
$view->name = 'blog_date_browse';
$view->description = 'Sort the blog information by date.';
$view->access = array (
);
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = '';
$view->page_header = '';
$view->page_header_format = '4';
$view->page_footer = '';
$view->page_footer_format = '4';
$view->page_empty = '';
$view->page_empty_format = '4';
$view->page_type = 'node';
$view->url = 'blog-content';
$view->use_pager = TRUE;
$view->nodes_per_page = '10';
$view->sort = array (
array (
'tablename' => 'node',
'field' => 'created',
'sortorder' => 'DESC',
'options' => 'month',
),
);
$view->argument = array (
array (
'type' => 'year',
'argdefault' => '2',
'title' => '',
'options' => '',
'wildcard' => '',
'wildcard_substitution' => '',
),
array (
'type' => 'month',
'argdefault' => '2',
'title' => '',
'options' => '',
'wildcard' => '',
'wildcard_substitution' => '',
),
);
$view->field = array (
array (
'tablename' => 'node_data_field_month',
'field' => 'field_month_value',
'label' => '',
'handler' => 'content_views_field_handler_group',
'options' => 'default',
),
array (
'tablename' => 'node',
'field' => 'created',
'label' => '',
'handler' => 'views_handler_field_date_small',
),
);
$view->filter = array (
array (
'tablename' => 'node',
'field' => 'type',
'operator' => 'OR',
'options' => '',
'value' => array (
0 => 'regular_blog',
),
),
);
$view->exposed_filter = array (
);
$view->requires = array(node, node_data_field_month);
$views[$view->name] = $view;
Comments
Comment #1
sunPlease submit a proper patch. It will probably included in 1.7.
Comment #2
sunThis has already been fixed in CVS.
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/views/views...
Comment #3
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.