Search API Sort Module In Drupal 7

Search API Sort Module

In one of our project, we have to list all post of a content type with search and sort functionality. And the main thing was search form was in the header whereas sort fields were a location in another region.
              
Therefore when we explore search and sort fields from view, both the fields were coming up together.
              
There are two options to overcome this situation:
         

  • Block Clone module

There is one contrib module “Block Clone” is available.
Using this module you can set single block at multiple places.
To solve our above problem we can set expose fields block at two places. and using CSS/jQuery we need to hide/show relative fields as per the block position (like for search block, hide sort fields).
              

  • Search API Sorts

As we already have used Search API module, we go with Search API Sorts contrib plugin.

This module is dependent on Search API module. This module creates a separate block only for sort fields.

  • We need to follow below steps to configure this module:
  • Install and activate this module
  • After activating this module, you can able see link in admin i.e. configuration >> Search and Metadata >> Search API. Select it.
  • You need to create an index first over there.
  • After creating Index, there will be a tab named "SORTS".
  • In that tab, you can able to select fields which you want to make it sortable.

              
By doing this, it will create a separate block for sorting fields & you can place that block where you actually need it.

Hope this helps you well, feel free to add your comments/feedbacks. Need more assistance regarding Custom Drupal Development Get in touch today!