Hi!
Im having an issie with the latest Views2 release regarding the sort criteria. Im using views to create a view of the node type "Events" with the newest node on top. So on sort criteria im sorting on "Nid Desc".
But, regardless the sort criteria im using, the oldest node is allways on top. I've allrdy tried to clear my caches etc, but with no result.
Can u guys check my code?
Thnx in advance!
greets, Frank
$view = new view;
$view->name = 'Events';
$view->description = 'Events';
$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('sorts', array(
'nid' => array(
'order' => 'DESC',
'id' => 'nid',
'table' => 'node',
'field' => 'nid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'type' => array(
'id' => 'type',
'table' => 'node',
'field' => 'type',
),
));
$handler->override_option('filters', array(
'type' => array(
'operator' => 'in',
'value' => array(
'event' => 'event',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 3);
$handler->override_option('use_pager', '1');
$handler->override_option('use_more', 0);
$handler->override_option('use_more_text', 'Lees verder');
$handler->override_option('distinct', 0);
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
'relationship' => 'none',
'build_mode' => 'teaser',
'links' => 1,
'comments' => 0,
));
$handler = $view->new_display('page', 'Pagina', 'page_2');
$handler->override_option('path', '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
Comment #1
darthf1 commentedSorting on Date Published doesnt work either. If i use the views SQL code in PHPMyAdmin, it does show the latest item first.
Comment #2
darthf1 commentedSorting does work on row style: Fields, but not on row style: node
Comment #3
dawehnerdid you had a look at the query.
Is there ORDER BY node_nid DESC // or something similar included?
Comment #4
darthf1 commentedYes it is included. Like i said, when i use the exact query Views gave me in PHPMyAdmin, it returns the correct rows. The weird thing is, when i put my view on "Row Style: Fields" it DOES sort, but not when im using "Row Style: Node"
SQL says:
SELECT node.nid AS nid,
node.nid AS node_nid
FROM node node
WHERE (node.type in ('story')) AND (node.status <> 0)
ORDER BY node_nid DESC
Comment #5
merlinofchaos commentedThe row style has absolutely no effect on the order that nodes are retrieved, or displayed. There is no way it can be the problem here.
Since you're not whitescreening, this is not critical. Please don't overestimate your own importance.
Comment #6
darthf1 commentedWell it is exactly the problem. Im using the row style fields now, and everything is displayed normally.
Sorry about the importance, i thought that an error in sorting had quite an impact.
Comment #7
giorgoskMy last experience with views (surely a complex beast)
When using style:tables the sorting criteria do not work
you have to use the table style settings instead and specify what sorting should be done
but you have to include the sorting parameters as a field (and exclude it from display)
OR
after using Override normal sorting if click sorting is used in your table settings
(probably a default value) and sorting criteria should be working again
is that behaviour by design ?
very similar report found here #56073: Sort in table view doesn't work node changed attribute
Comment #8
merlinofchaos commentedI am unable to duplicate this behavior. Is it possible that some other module is actually handling things and not actually the view?
Comment #9
Sera commentedThe problem is still there in v.6.x-2.8
Please see attached screenshot. The different fields in a style:table could not be clicked as being "sortable".
Comment #10
dawehnerAre you not searching the issue queue? http://drupal.org/node/657700#comment-2394288
Comment #11
Sera commentedSorry I did, but this was the first issue I found. Thank you nevertheless for the link with the patch. :)
Comment #12
elgwiedo commentedI am having the same problem to sort on publish date. It does not sort at all, all nodes are put there randomly.
Comment #13
drupaleze commentedSort date not working with table style in views?
This solved it for me: Click SETTINGS in TABLE format and select NONE for sort! Hope it helps you too ;)