function hook_search_api_sorts_default_sort_alter in Search API sorts 7
Same name and namespace in other branches
- 8 search_api_sorts.api.php \hook_search_api_sorts_default_sort_alter()
Alter the Search API sorts default sort.
Modules may implement this hook to alter the default sort used by Search API sorts module.
Parameters
object $default_sort: The Search API sort object used as default sort.
array $search_sorts: An array of all enabled Search API sort objects.
$keys: The searched terms
See also
_search_api_sorts_get_default_sort()
1 invocation of hook_search_api_sorts_default_sort_alter()
- _search_api_sorts_get_default_sort in ./
search_api_sorts.module - Helper function to get the default sort field.
File
- ./
search_api_sorts.api.php, line 28 - Hooks provided by the Search API sorts module.
Code
function hook_search_api_sorts_default_sort_alter(&$default_sort, array $search_sorts, $keys) {
// Example which alters the default sort to use title instead. This is
// example does not make a difference between default and a search page with
// search queries provided.
foreach ($search_sorts as $search_sort) {
if ($search_sort->field == 'title') {
$default_sort = $search_sort;
}
}
}