According to the documentation, the table theme should be able to respond to the field argument for the purpose of a sort order. This is not true. It uses the data argument to build the query, and the logic in tablesort relies on the cell['data']. I can fix this. Being newer to drupal, I wanted to verify this behavior before I assign it to myself and fix it. Please let me know your thoughts and I will check in my fix.

Comments

Anonymous’s picture

Project: Drupal.org infrastructure » Drupal core
Version: » 6.x-dev
Component: Drupal.org theme » documentation

I am moving the report to the correct queue.

jhodgdon’s picture

Status: Active » Reviewed & tested by the community

Which documentation are you reading/following?

jhodgdon’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

Sorry, wrong status change.

Anonymous’s picture

Version: 7.x-dev » 6.x-dev

I guess he is referring to http://api.drupal.org/api/function/theme_table/6, or to any tablesort_*() function that is called by theme_table().

jhodgdon’s picture

Version: 6.x-dev » 7.x-dev

I would like more explanation of what the reporter really thinks is wrong, and whether the reporter thinks it is a documentation error or an error in the function logic. It's not clear to me from the issue report, and not being an expert on the sort argument to table theming, I cannot say for sure.

Also, it looks like the table sorting and table theming is fairly similar in Drupal 7 to what it is in Drupal 6, so it should probably start there.

wbossons’s picture

Version: 6.x-dev » 7.x-dev

The documentation states that the field argument can be used to specify which column to sort. That doesn't actually work.

jhodgdon’s picture

Version: 7.x-dev » 6.x-dev
Component: documentation » theme system
Category: bug » support

There are several places in Drupal core where this is working. For instance, if you have the Database Logging module on, and visit the "Recent Log Entries" report, you can click on the "User" column header and it will sort the report by user name (rather than the default date sort).

This works in both Drupal 7 and Drupal 6.

So I don't think there is a bug in the theme_table() function. You might look at the code in dblog.admin.inc that uses the theme function and see what it is doing that you aren't. And if you feel that the documentation has something left out, please add another comment to this issue.

In the meantime, I think this is a support issue in theming rather than a code or documentation bug in Drupal, and I'm assuming it's Drupal 6.

berdir’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

I just moved a duplicate of this to the documentation issue queue, see #839634: Fix up documentation for table sorting. My post there contains more exact information of what's wrong - theme_table() indicates that 'sort' can be used to define the "default sorting order of a column". However, that is incorrect, 'sort' actually defines the default sorting *column* and the sorting order of that column.

You can't have multiple 'sort' definitions, that results in undefined behavior as the above issue shows. That issue has also a link to a feature request which would allow it.