Skip to content

Instantly share code, notes, and snippets.

@pedrorocha-net
Created March 2, 2015 11:14
Show Gist options
  • Save pedrorocha-net/f7fe05a018b8e1917577 to your computer and use it in GitHub Desktop.
Save pedrorocha-net/f7fe05a018b8e1917577 to your computer and use it in GitHub Desktop.
Drupal Search module customisation to allow display priority settings for each content type (to allow showing certain types first in the default search module)
function HOOK_ranking() {
$rankings = array();
$types = node_type_get_types();
foreach ($types as $type) {
$rankings[$type->type . '_node_type_boost_search'] = array(
'title' => t('Boost "' . $type->name . '" nodes'),
'arguments' => array(':type' => $type->type),
'score' => ' FIND_IN_SET(n.type, :type)',
);
}
return $rankings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment