2005-09-28
sabio
When the search query 'looks' like a page name (contains namespace prefix) and corresponding page exists instead of displaying (empty?) search results user can be redirected to that page.
So, for example, searching for 'development' will show search results (with page name matches as well). But running a search for 'wiki:development' will go directly to that page. Pretty convenient, IMO. :-)
To achieve this you just need to change the following code in 'inc/actions.php'
//check if searchword was given - else just show
if($ACT == 'search' && empty($QUERY)){
$ACT = 'show';
}
to
if ($ACT == 'search') {
//check if searchword was given - else just show
if (empty($QUERY))
$ACT = 'show';
//if query is a page name with a namespace specified
//and the page exists - just go directly there
elseif (strpos($QUERY,':')!==false) {
$id = $QUERY;
resolve_pageid(getNS($QUERY),$id,$exists);
if ($exists) {
$QUERY = $id;
$ACT = 'show';
}
}
}
Feel free to comment/improve the code above. :-)