LIVE FROM THE MINNESOTA SEARCH SPRINT, this patch refactors the advanced search form and search keys so that modules can add additional "things" to search on. In the current code only node types, taxonomy terms, and languages are added to the advanced search form. Then, everywhere the search keys are processed, these three special use cases are checked for.
This patch makes the system more generic.
I've added two new hooks, hook_searchform and hook_searchkeys:
hook_searchform returns the form that gets added to the advanced search fieldset. For example,
function taxonomy_searchform() {
if ($taxonomy = taxonomy_form_all(1)) {
$form['category'] = array(
'#type' => 'select',
'#title' => t('Only in the category(s)'),
'#prefix' => '<div class="criterion">',
'#size' => 10,
'#suffix' => '</div>',
'#options' => $taxonomy,
'#multiple' => TRUE,
);
return $form;
}
}
Notice that the form returned does not included $form['advanced']
because it is relative to the advanced fieldset.
hook_searchkeys returns the keys used in this form along with the SQL to generate. hook_searchkeys may may also return additional join clause. For example,
function taxonomy_searchkeys() {
return array(
'category' => array(
'where' => "tn.cid = '%s'",
'join' => ' INNER JOIN {term_node} tn ON n.vid = tn.vid'
),
);
}
I'm open to different hook names.
This patch accomplishes similar refactoring to the search_rankings patch #145242, although the two patches refactor different things for different purposes.