This is a follow-up to #905900: Date sorting is not working correctly. (replying to this issue doesn't work at the moment, and it's a different issue anyway).

Inserting

<?php
        ...
        }
        var_dump(array($field, $code)); exit();
        $sorter = create_function('$a,$b', $code);
        ...
?>

outputs:

array(2) { [0]=> string(12) "display-name" [1]=> string(148) "$a=isset($a["display-name"])?$a["display-name"]:"";$b=isset($b["display-name"])?$b["display-name"]:"";return -strcmp(strtolower($a),strtolower($b));" }

Does this help you?

CommentFileSizeAuthor
#12 filebrowser-err.patch809 bytesclaudiu.cristea

Comments

Yoran’s picture

Status: Needs review » Postponed (maintainer needs more info)

okay so you made a new ticket :)

In the previous one I was asking if you have the same problem with integer fields (like dates)

.

asb’s picture

Status: Active » Postponed (maintainer needs more info)

I have two columns, "Display name" and "size". With filebrowser-6.x-2.x-dev from 2010-Sep-19, sorting these columns now works fine after clicking on the table header. File (file) size is an integer value, I believe.

The default sorting, configured in "Folder presentation" -> "Default sorting" doesn't work for me; also, the settings for "Visible columns" seem to be ignored (I can't get something else displayed, like "description", or "created").

HippoOnDiet’s picture

Hi Yoran,

I just want to confirm ASB's issue.

When I tried to set default_sort to display name or description - it does not do anything at all.
I can't see any arrow up or down besides the header.

However if you click on Display_Name header then it will sort it for you.

I tested on Modified date as well.
When I select Modified date as default - nothing is sorted as well, until you click on the header.

Thanks again.

giando58’s picture

Hi Yoran,

I confirm also: default_sort setting for Modified date doesn't work too, still it is possible to click on its header to sort tha table as well.

Thanks a lot

benlotter’s picture

I get the following errors when clicking on the sort filename. The filenames all start with numbers (the date). Can we make a checkbox to remove the sort capability (or limit by field)? I am using sorttable.js in another section of the site (http://fallsbc.org/Sermons). There I have full control over how each column is sorted... notice it even sort the Bible passage correctly as well as the file sizes, dates and other text fields.

•warning: usort() [function.usort]: Invalid comparison function in /home/MYDIR/public_html/addons/ministryfree/sites/MYSITE.com/modules/filebrowser/filebrowser.theme.inc on line 201.
•warning: usort() [function.usort]: Invalid comparison function in /home/MYDIR/public_html/addons/ministryfree/sites/MYSITE.com/modules/filebrowser/filebrowser.theme.inc on line 205.

Nicolas Georget’s picture

Benlotter,

Your errors come from an another issue: #841372: usort() Invalid comparison function
There's a patch available here: http://drupal.org/node/841372#comment-3396542

stefan vaduva’s picture

I had the same problem and I've solved it by adding this line

...
$table_sort['sql'] = str_replace('-', '_', $table_sort['sql']);
...

in filebrowser.theme.inc before

...
// Sort files according to correct column.
    if ($table_sort['sql']) {
      usort($just_folders, "_filebrowser_sorter_" . $table_sort['sql']);
      if ($table_sort['sort'] == 'asc') {
        $just_folders = array_reverse($just_folders, TRUE);
      }
      usort($just_files, "_filebrowser_sorter_" . $table_sort['sql']);
      if ($table_sort['sort'] == 'asc') {
        $just_files = array_reverse($just_files, TRUE);
      }
...

[edit] I must specify that this was just a quick hack to get the sort working. I haven't investigate why this is happening. [/edit]

ianchan’s picture

#7 works for me. thanks!

andreak’s picture

$table_sort['sql'] = str_replace('-', '_', $table_sort['sql']);

also worked for me and got rid of the error. Thanks! -Andrea

pierrelbz’s picture

Work for me too

Thanks !

wogga’s picture

Any news about the problem that default sorting doesn't work? (Post #2, #3, #4)

claudiu.cristea’s picture

StatusFileSize
new809 bytes

Optimized patch.

claudiu.cristea’s picture

Status: Postponed (maintainer needs more info) » Needs review
Yoran’s picture

Did you try the dev version our the last RC version (this ticket is marked 6.x-2.x-dev, that's why I ask). Normally this bug is gone by using php create_function instead of using static sorters.

Yoran’s picture

Status: Postponed (maintainer needs more info) » Fixed

Well no news, I assume it's ok

Status: Fixed » Closed (fixed)

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