Sortable Views in Drupal 6

I’m completely new to Drupal, I’ve heard a lot about it and I know some evangelists, but I’ve never had reason to use it – until now. So, I might be using the wrong words for things or not explaining things too well, but I’m going to record this because it took me so long to find, and I might need it again.

I am working the Workflow Summary page, which is populated by a view. This view has fields, filters and I can specify the sort order for it, which is all great and it has a surprisingly accessible interface considering all the ajax and whatever else that is going on in there. But the users wanted to be able to re-sort the columns as they went along. Guess what? Drupal already has a way to do this!

  1. Edit the view you want to add the column sorting to
  2. Under “Basic Settings”, look for “Style: Table” and click on the picture of a cog next to it. (if I were a serious blogger, I’d screenshot. Never mind, eh?)
  3. Scroll down to see the table settings
  4. There is a list of the fields, and a tickbox for each labelled “sortable” – tick the boxes for any columns you want users to be able to change the sort order on

I didn’t find this very fast but thanks to some help from #drupaluk on freenode someone pointed me in the right direction – my columns now have clickable headers and resort as expected! If this helps, or if you have any more tips for this type of thing, please do add a comment.

6 thoughts on “Sortable Views in Drupal 6

  1. Lorna

    Your tip is very useful! I’ve just finished a Drupal site which is quite complex and uses several View tables. (There is loads more to see for logged in users). However, I didn’t know about columns being sortable by the user.

    Where did you get your help from? I could have done with some.

    Have you updated Views from 2.2 to 2.3? There is a bug which affects some table layouts. It took me forever to find. I can’t show you as it is on a page only visible to logged-in users.

    Please post any more Drupal tips and let me know if you get stuck again. I might be able to help!

  2. Jane: My help comes entirely from the IRC channel #drupaluk on freenode, I’m new there but they’ve been friendly. I’m not certain which version of views 2 we’re using but I managed to avoid any table layout bugs – so that’s lucky :) Thanks so much for your offer of help, in return I’ll keep posting any snippets I come across!

  3. Again a very great post, LornaJane!
    At the moment I don’t happen to manage any site where this information would be that useful. Though I can imagine many circumstances where it would be. Your page explains and fixes many of my problems.

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.