Place this hook_search in you module any where to create custom search.
You can modify query and content as per need.
Given example will create custom search on user-aliases
Code :
* hook_search ()
* This will enable mysearch as custom search tab in menu on search page
* @param $op - opreation prarameter
* @param $keys - key parameter
*/
function mysearch_search($op = 'search', $keys = NULL) {
switch($op) {
case 'name':
return t("My search");
break;
case 'search':
$found = array();
$keys = preg_replace('!*+!', '%', $keys);
$sql = "SELECT * FROM {url_alias} WHERE LOWER(dst) LIKE LOWER('%%%s%%')";
$result = pager_query($sql, 50, 0, NULL, $keys);
while ($path = db_fetch_object($result)) {
$found[] = array('title' => $path->dst,
'link' => url("admin/build/path/edit/$path->pid"));
}
return $found;
break;
}
}
Comments
Use this to add custom search in your site
Place this hook_search in you module any where to create custom search.
You can modify query and content as per need.
Given example will create custom search on user-aliases
Code :
* hook_search ()
* This will enable mysearch as custom search tab in menu on search page
* @param $op - opreation prarameter
* @param $keys - key parameter
*/
function mysearch_search($op = 'search', $keys = NULL) {
switch($op) {
case 'name':
return t("My search");
break;
case 'search':
$found = array();
$keys = preg_replace('!*+!', '%', $keys);
$sql = "SELECT * FROM {url_alias} WHERE LOWER(dst) LIKE LOWER('%%%s%%')";
$result = pager_query($sql, 50, 0, NULL, $keys);
while ($path = db_fetch_object($result)) {
$found[] = array('title' => $path->dst,
'link' => url("admin/build/path/edit/$path->pid"));
}
return $found;
break;
}
}