I need to implement the functionality of sorting the content listed to the user based on attributes like alphabetically, popularity or price (ascending/descending). These attributes can also be custom. I need to have it has a widget. I don't exactly know what this functionality is called so apologies if I'm not being clear.

I also need to display text like "Displaying % of %" on top the list which, as far as I've seen, views don't do by default.

An example could be this website.

I'm using Drupal Commerce (D7).

So is there a module for this?

  • You can achieve the sorting functionality with Views core : setup a table display and choose the sortable columns in its properties. Very straightforward.
    – Countzero
    May 29, 2012 at 12:43
  • 1
    What you suggest is obviously straightforward but that's not what I want. I need to have a separate widget to do the sorting on the basis of the mentioned attributes. Did you read the question or see the link example? May 29, 2012 at 12:57
  • I read the new version, but the old one wasn't that clear.
    – Countzero
    May 29, 2012 at 13:01

1 Answer 1


Views allows you to expose sorts, but doesn't create the type of UI you are asking for by default.

What you get by default with views after clicking 'expose' at the top of your sort value is two menus, one for the value to sort by, and one for the sort direction.

The most important thing to remember here is what you get in your view's url after submitting this original exposed filter form: /myviewpath?sort_by=XXXXX&sort_order=XXXXX.

You can write your own custom module, do a hook_form_alter of the existing form, a fancy jquery widget, heck write it in Flash if you really want to, all the view cares about is you passing those two values and that those values are enabled and available for that view.

In terms of getting your own custom values available there have a look at the views sort class documentation and the view_handler_sort_* examples already provided in /views/handlers. Views argsort looks pretty interesting as well if you don't want to write your own sort handler but haven't tried that module myself yet.

For part 2 of your question this summary is already provided by views. Click on header, click on "Global Result Summary", and use the tokens provided to create your summary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.