Skip to content Skip to navigation

Need to Sort a View in a Specific Order?

Often we run into a common problem where clients want to have their Staff listed in a particular order not just ascending or descending alphabetically. We can easily solve this using a great module called Draggable Views. I love using Draggable Views!  Here's my quick lesson on how to use this awesome module for Drupal 7.

Step 1 - Build your initial public-facing view.  Let's call it "Staff." This will be the final view that is shown on the site.

Step 2 - Then build a second view and call it "Sort Staff." This will be used to create the custom sort order, and is not ultimately seen on the site.

  • It's important that this be a table view of fields. 
  • Add one or two fields that will help you when creating your custom sort order. In this case I include the first and last names of our staff members.
  • Add a field for Draggableviews: Content
  • Add a sort criteria for Draggableviews: Weight
  • Then change the path to something like /admin/sort-staff
  • Then save this view.

Step 3 - Go back to your "Staff" view to set the sort order based on our "Sort Staff" view.

  • Remove any existing sort criteria that exists (for example, ascending)
  • Add a sort criteria for Draggableviews: Weight
  • In the "Configure sort criterion: Draggableviews: Weight" settings, under the "Display sort as" section, select the new "Sort Staff" (Page) view that you just created.
  • Apply and Save.

Step 4 - Now that you've connected your "Staff" view with the "Sort Staff" view, you can create your custom sort order.

  • Go to your public-facing "Staff" view page.
  • Hover over the view and click the "cog wheel" in the upper right corner.  You should see an "Order view" option. 
  • After selecting "Order view" you can arrange your content by using the draggable double-pointers. 
  • Make sure to click Update!

Voila!  A sorted view just the way the client wants it!

Categories: 

Comments

My requirement in views is, i have some fields. in that image field is also one, so i want to show image in left side and remaining in rightside of the view.. please help me regarding this.

Hi Suraj, In order to accomplish field placement vs. content order, you should consider using CSS. Read our blog post Styling on Sites: Introduction to CSS Injector. You can also try adding a view rewrite field to manipulate the display using tokens.