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,
));
CommentFileSizeAuthor
#9 view-style-table.jpg245.02 KBSera

Comments

darthf1’s picture

Sorting on Date Published doesnt work either. If i use the views SQL code in PHPMyAdmin, it does show the latest item first.

darthf1’s picture

Category: support » bug
Priority: Normal » Critical

Sorting does work on row style: Fields, but not on row style: node

dawehner’s picture

did you had a look at the query.

Is there ORDER BY node_nid DESC // or something similar included?

darthf1’s picture

Yes 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

merlinofchaos’s picture

Priority: Critical » Normal

The 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.

darthf1’s picture

Well 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.

giorgosk’s picture

Title: Sorting not working. » Sorting not working with table style

My 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

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)

I am unable to duplicate this behavior. Is it possible that some other module is actually handling things and not actually the view?

Sera’s picture

Version: 6.x-2.6 » 6.x-2.8
Status: Postponed (maintainer needs more info) » Needs work
StatusFileSize
new245.02 KB

The 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".

dawehner’s picture

Status: Needs work » Closed (duplicate)

Are you not searching the issue queue? http://drupal.org/node/657700#comment-2394288

Sera’s picture

Sorry I did, but this was the first issue I found. Thank you nevertheless for the link with the patch. :)

elgwiedo’s picture

I am having the same problem to sort on publish date. It does not sort at all, all nodes are put there randomly.

drupaleze’s picture

Sort 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 ;)