|
Cookbook /
SearchResultsSummary: How to change the way search results are displayed
Version:
Prerequisites:
Status:
Maintainer:
QuestionHow can I change the way search results are displayed? Answer
QuestionHow can I add a link to create a new page on the search results page when no matches were found? AnswerAdd this "hack" to the Replace this, on line 55:
XLSDV('en', array(
'SearchFor' => 'Results of search for <em>$Needle</em>:',
'SearchFound' =>
'$MatchCount pages found out of $MatchSearched pages searched.'));
With this:
if($MatchCount < 1) {
$xlsdvArgs = array(
'SearchFor' => 'Results of search for <em>$Needle</em>:',
'SearchFound' =>
'<p>No results found. Create a new page for
"<a href="index.php/Main/$Needle">$Needle</a>"</p>');
}
else {
$xlsdvArgs = array(
'SearchFor' => 'Results of search for <em>$Needle</em>:',
'SearchFound' =>
'$MatchCount pages found out of $MatchSearched pages searched.');
}
XLSDV('en', $xlsdvArgs);
QuestionHow can I exclude pages such as RecentChanges or GroupHeader from being displayed in search results and page lists? AnswerThe list=normal ParameterPmWiki pre-defines a " (:pagelist group=Cookbook list=normal:)
gives a list of all "normal" pages in the Cookbook (pages except for RecentChanges, GroupHeader, etc). Defining Custom ParametersPmWiki's default is to display all pages; but a wiki administrator can override this default by adding entries to For example, to define " $SearchPatterns['calendar'][] = '/\\.\\d{4}-\\d\\d-\\d\\d$/';
With this definition, the markup For search exclusions, use patterns delimited by exclamation points. Thus an administrator can define " $SearchPatterns['norc'][] = '!RecentChanges$!';
To change the default listings to exclude RecentChanges, AllRecentChanges, GroupHeader, and etc., use something like: $SearchPatterns['default'][] = '!\\.(All)?Recent(Changes|Uploads)$!'; $SearchPatterns['default'][] = '!\\.Group(Print)?(Header|Footer|Attributes)$!'; Similarly, you can exclude groups. $SearchPatterns['default'][] = '!^Site\\.!'; $SearchPatterns['default'][] = '!^PmWiki\\.!'; QuestionHow can i make the Search should use the Group it is called from to return the result For example you may use a customised search page, say TTC/Search
AnswerIt appears this can be achieved by the following steps
See also Alternatively try
(:searchbox size=24 group=TTC target=TTC.Search:)
(:if equal {$Action} "search":)
(:searchresults list=normal name=-template:)
(:ifend:)
See AlsoCommentsIf you're using PmWiki as a CMS, the following lines in your local/config.php will exclude wiki-related pages from searches without a ## Exclude Certain pages / groups from search results. $SearchPatterns['default'] = array( 'recent' => '!\.(All)?Recent(Changes|Uploads)$!', 'group' => '!\.Group(Print)?(Header|Footer|Attributes)$!', 'pmwiki' => '!^(Site|PmWiki)\\.!' ); Contributors
|