Hi,
The /includes/theme.inc/theme_table($header, $rows...) function offers support to make HTML tables sortable, by turning the column headers in links (hrefs) that have a "sort=" and "order=" parameter.
This works as advertised except for the fact that the "order" parameter in the URL produced is not the database table field (as specified via the $header argument, explained in the instructions above function theme_table()), but the column header text (which may be translated in a foreign language).

It seems that line 92 in function tablesort.inc/tablesort_header() may carry part of the blame:

function tablesort_header($cell, $header, $ts) {
    ...

    $cell['data'] = l($cell['data'] . $image, $_GET['q'], array('attributes' => array('title' => $title), 
       'query' => 'sort='. $ts['sort'] .'&order='. urlencode($cell['data']) . $ts['query_string'], 'html' => TRUE));

    ...
}

Changing the '&order='. urlencode($cell['data']) to '&order='. urlencode($cell['field']) produces the correct URLs, however, this breaks the sorting for all but the default sorting column.
So a more comprehensive fix is required.

Comments

RdeBoer’s picture

Knock, knock... anyone there?

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.