Sortable Views in Drupal 6
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!
- Edit the view you want to add the column sorting to
- 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?)
- Scroll down to see the table settings
- 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.
Lorna
Your tip is very useful! I’ve just finished a Drupal site http://www.manchesterquakers.org.uk/ 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 http://drupal.org/node/372227 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!
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!
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.
That was just the tip that I needed. Never ever noticed that before and I’ve been using Drupal for months.
Thanks
Awesome, exactly what I was looking for. I knew Views had to have this, just didn’t know where to look.
Thanks! Exactly what I was looking for!