function search_data($keys = NULL, $type = 'node') {
// $keys 需要搜索的关键字
// $type 搜索的类型
if (isset($keys)) {
if (module_hook($type, 'search')) {
//寻找对应module中的hook_search并调用返回结果
$results = module_invoke($type, 'search','search', $keys);
if (isset($results) &&is_array($results) && count($results)) {
if (module_hook($type, 'search_page')){
// 结果以module中的hook_search_page呈现
return module_invoke($type,'search_page', $results);
}
else {
// 结果以search_results呈现
return theme('search_results',$results, $type);
}
}
}
}
}
从以上代码可以得知,只要在module中实现hook_ssearch,就可以实现自定义搜索功能。如果有需求,可以在module实现hook_search_page来定制结果输出模板。