This appears to be new in 2.8: "Override normal sorting if click sorting is used" on table style views isn't respected anymore. Regular sort rules are still being applied in addition to the click sorting, with the regular sort rules taking precedence.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Les Lim’s picture

Here's an export, just in case:

$view = new view;
$view->name = 'test2';
$view->description = '';
$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' => 'Title',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'teaser' => array(
    'id' => 'teaser',
    'table' => 'node_revisions',
    'field' => 'teaser',
  ),
  'sticky' => array(
    'label' => 'Sticky',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'type' => 'yes-no',
    'not' => 0,
    'exclude' => 0,
    'id' => 'sticky',
    'table' => 'node',
    'field' => 'sticky',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'sticky' => array(
    'order' => 'DESC',
    'id' => 'sticky',
    'table' => 'node',
    'field' => 'sticky',
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'story' => 'story',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => 'type_op',
      'label' => 'Node: Type',
      'use_operator' => FALSE,
      'identifier' => 'type',
      'remember' => FALSE,
      'single' => TRUE,
      'optional' => TRUE,
      'reduce' => FALSE,
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
  'grouping' => '',
  'override' => 1,
  'sticky' => 0,
  'order' => 'asc',
  'columns' => array(
    'title' => 'title',
    'teaser' => 'teaser',
    'sticky' => 'sticky',
  ),
  'info' => array(
    'title' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'teaser' => array(
      'separator' => '',
    ),
    'sticky' => array(
      'sortable' => 1,
      'separator' => '',
    ),
  ),
  'default' => '-1',
));
$handler->override_option('row_plugin', 'editview');
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'pages');
$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,
));
dawehner’s picture

Status: Active » Closed (duplicate)
merlinofchaos’s picture

Status: Closed (duplicate) » Needs review
FileSize
3.8 KB

Making this one active, since the linked issue is a total mess.

Les Lim’s picture

Status: Needs review » Reviewed & tested by the community

That was it. Don't think this needs any more eyes on it.

dww’s picture

Status: Reviewed & tested by the community » Fixed

Ran into this same bug. Thankfully, dereine pointed me to this issue. Reviewed and tested the patch -- works like a charm and is obviously correct. Wrote a CHANGELOG entry and committed to DRUPAL-6--2, DRUPAL-6--3, and DRUPAL-7--3 (same patch applied to all 3 branches).

watbe’s picture

http://drupal.org/node/666408 was a duplicate. patch works great, thanks a lot for that.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

gaellafond’s picture

I figured out that the bug only apply if you have all the following:
* A view with more that 1 field
* Basic settings: Style: Table
* Table settings: Default sort: none
* Table settings: Override normal sorting if click sorting is used checked
* Sort criteria added on one of the view column

Also, because the views are cached, you have to clear the cache to actually see the bug:
Administer > Site building > Views > Edit view recent_content > Tools
Click on Clear Views' Cache

BWPanda’s picture

Version: 6.x-2.8 » 6.x-2.10
Status: Closed (fixed) » Active
FileSize
13.34 KB

I'm experiencing this issue in Views 2.10... I've attached an export of my view.
Anyone else still having this issue, or is it something I'm doing wrong?

drooopalstars’s picture

merlinofchaos..
You rock!

I was having same problem of "Override normal sorting" not working with table_style
Just change on one line saved me
655770-build-sort-bad-parens.patch

Thanks so much!

Letharion’s picture

Assigned: Unassigned » merlinofchaos
Status: Active » Reviewed & tested by the community

@merlinofchaos
I take it the patch is "done", but hasn't been committed yet?

merlinofchaos’s picture

Assigned: merlinofchaos » Letharion
Status: Reviewed & tested by the community » Active

The patch in this issue was committed back for Drupal 2.8.

Can you confirm that either of the above repro instructions still have this issue?

iamjon’s picture

Status: Active » Closed (fixed)

I cannot reproduce. Please feel free to reopen but provide an export using common content types and simple fields.

gaellafond’s picture

I describe the minimum requirement to reproduce the bug on my post (#8). Maybe the bug has been fixed in the latest version, I can not test it right now. If not, I will try to provide a minimalist export as suggested.

boabjohn’s picture

FileSize
31.24 KB

G'Day all,
This issue has a long history, but seems to fit my problem exactly. So, we are:
Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.18 with Suhosin-Patch
Pressflow 6.22
Views 6.x-2.16

I've attached an export of the view which uses 2 content taxonomy fields (sortable via their taxonomy relationships) and a plain node title field.

When the "Overide default sort" is ticked *on*, the column sorts work just fine, but we get a random sort when the table is first loaded (ie, the default sort is ignored)

When the "Overide default sort" is ticked *off*, the default sorts (three terms) work as expected on the initial view, but the column sorts do not function.

What I expect is this:
1. We should be able to specify a default sort, using more than one field (eg, sort first by theme, then by author, then by title)
2. We can set up any number of fields to be click sortable colun headers.
3. If the Overide setting is ticked *on*, the user should be able to click sort on column headers to "overide" the default sort (although they can obviously only sort on a single column since there is no multi-field click sorting possible)

Where are we going wrong in this picture?

The live view (has a few more columns) is here: http://www.ccrspi.org.au/conference/ccrspi-conference-2011
The trimmed version (attached) is also accessible, down the page, under the main table.

Thanks indeed for any pointers or help!
Kind regards,
JB

boabjohn’s picture

Version: 6.x-2.10 » 6.x-2.16
Status: Closed (fixed) » Active
couturier’s picture

Status: Active » Closed (won't fix)

Developers are working in D7 and D8 now.

pelicani’s picture

Version: 6.x-2.16 » 7.x-3.x-dev
Status: Closed (won't fix) » Needs review

This is still an issue in views 3 for drupal 7.
This issue has been reported since 2009.
I looked for a resolution and response to the outlined solution,
but have found none.

The summary seems simple,
leave the default sort and apply after someone uses the click sort
or don't use the default sort and only use the click sort.

Can someone look at this and determine if it can still be worked on?
I'll keep looking at how to do this, but I'm not having much luck.

Status: Needs review » Needs work

The last submitted patch, 655770-build-sort-bad-parens.patch, failed testing.

couturier’s picture

@pelicani If you want a solution, I think this issue needs to be closed and a new one opened for Version 7. You can't just switch an issue from Drupal 6 to 7 without leaving plenty of comments that don't apply. The patch above worked in Drupal 6.

itapplication’s picture

Subscribing for Drupal 7.
Why module developer ignore this bug while developing or upgrading module for Drupal 7
Why not module developer apply patch into next release of module.