This website recently got a major rebuild; if you're missing something, let Lorna know.

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.


In: php
Tags: #drupal #php