Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
7 Jan 2007 at 19:42 UTC
Updated:
25 Aug 2008 at 20:23 UTC
Situation: a table view with many fields, most of which have sorting enabled and one is listed as the default sorting field. When one accesses the page view, everything seems fine, as the nodes are sorted according to the default sorting field. However, if one tries to sort according to any other field, the desired sorting doesn't happen and the default-sorted view is returned. Running: Views HEAD, Drupal head, Apache/2.0.59, PHP/5.1.6 and MySQL 5.0.19. Here's the view:
$view = new stdClass();
$view->name = 'workspace';
$view->description = 'Personal user workspace.';
$view->access = array (
0 => '3',
1 => '2',
);
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = 'My workspace';
$view->page_header = '';
$view->page_header_format = '1';
$view->page_footer = '';
$view->page_footer_format = '1';
$view->page_empty = '';
$view->page_empty_format = '1';
$view->page_type = 'table';
$view->url = 'workspace';
$view->use_pager = FALSE;
$view->nodes_per_page = '50';
$view->menu = TRUE;
$view->menu_title = '';
$view->menu_tab = FALSE;
$view->menu_tab_default = FALSE;
$view->menu_tab_weight = '0';
$view->sort = array (
array (
'tablename' => 'node',
'field' => 'created',
'sortorder' => 'DESC',
'options' => 'normal',
),
);
$view->argument = array (
);
$view->field = array (
array (
'tablename' => 'node',
'field' => 'type',
'label' => 'Type',
'sortable' => '1',
),
array (
'tablename' => 'node',
'field' => 'title',
'label' => 'Title',
'handler' => 'views_handler_field_nodelink',
'sortable' => '1',
'options' => 'link',
),
array (
'tablename' => 'node',
'field' => 'created',
'label' => 'Created',
'handler' => 'views_handler_field_date_small',
'sortable' => '1',
'defaultsort' => 'DESC',
),
array (
'tablename' => 'node',
'field' => 'changed',
'label' => 'Modified',
'handler' => 'views_handler_field_date_small',
'sortable' => '1',
),
array (
'tablename' => 'node_comment_statistics',
'field' => 'comment_count',
'label' => 'Comments',
'handler' => 'views_handler_comments_with_new',
'sortable' => '1',
),
array (
'tablename' => 'node',
'field' => 'edit',
'label' => '',
),
array (
'tablename' => 'node',
'field' => 'delete',
'label' => '',
),
);
$view->filter = array (
array (
'tablename' => 'node',
'field' => 'currentuid',
'operator' => '=',
'options' => '',
'value' => '***CURRENT_USER***',
),
array (
'tablename' => 'node',
'field' => 'distinct',
'operator' => '=',
'options' => '',
'value' => array (
0 => 'distinct',
),
),
);
$view->exposed_filter = array (
);
$view->requires = array(node, node_comment_statistics);
$views[$view->name] = $view;
Comments
Comment #1
merlinofchaos commentedYou have a sort criteria defined in that view. No table sorting will override that, but merely be appended to it. If you simply delete that sort criteria, I believe this view will work as you intend.
Comment #2
Permanently Undecided commentedGah, that'd never have occured to me. It works great now, thanks a lot, merlinofchaos!
Comment #3
(not verified) commentedComment #4
Memeshift commentedconfirmed working for me running Drupal 5.9 and Views 5.x-1.6! Thanks!