|
Cookbook /
SearchPatternsSummary: Q & A's on search patterns
Version:
Prerequisites:
Status:
Maintainer:
Categories: Searching
QuestionHow do I exclude certain pages from the search results? Answer
excludes MyGroup.ExcludeThisPage from the default search. QuestionA search for "/" displays the group name and the name of all the pages it contains. Names like Private.Budget seem to attract attention. By using various search terms, information can be gleaned from the supposedly private pages. For example, a search for "Project X" hits the page "Private.Budget", implying some discussion of the project in the budget. AnswerRemove the Private group from searches, by adding: $SearchPatterns['default'][] = '!^Private\.!'; $SearchPatterns['all'][] = '!^Private\.!'; $SearchPatterns['normal'][] = '!^Private\.!'; A side effect of the code above is that the (:pagelist:) markup no longer lists the Private pages. To make it work inside the Private group change your config.php to read: if (strncmp($pagename, 'Private.', 8) != 0) {
''as above
}''
This excludes the Private group from searches only if you're not already in the Private group. QuestionThe pagelist macro lists itself in its search.
Thus AnswerAdd the following to your config.php:
This will prevent a page from listing itself in QuestionHow can I include in a page the results of a search
for (/ -"PmWiki" -"Profiles") by using AnswerIf you're wanting to do exactly what it says -- i.e., display all pages
that do not have either "PmWiki" or "Profiles" in the text, then it's
just But if you're wanting to display all pages that are not in the PmWiki or Profiles groups, you'll probably want to create a custom search list: In config.php:
Then in the markup, use one of
This is somewhat described at Cookbook/SearchResults. QuestionIs there a way to create an exclusion array for groups to feed to Answer
If you want to exclude the PmWiki group from the "normal" page listings (i.e., via list=normal):
And if you want to create a list=restricted option that excludes a certain set of groups...
QuestionWhat is the syntax for excluding pages with the SearchPatterns? AnswerThe pagelist.php script contains: $SearchPatterns['normal'][] = '!\.(All)?Recent(Changes|Uploads)$!'; $SearchPatterns['normal'][] = '!\.Group(Print)?(Header|Footer|Attributes)$!'; You can add other patterns in local/config.php $SearchPatterns['default'][] = '!^PmWiki.*\.!'; The use of exclamation points as the pattern delimiters tells PmWiki
this is a pattern to be excluded from the list rather than included.
Similarly:
$SearchPatterns['default'][] = '!^BMIT\.!'; $SearchPatterns['default'][] = '!\.GroupHeader$!'; # exclude all GroupHeaders $SearchPatterns['default'][] = '!\.GroupFooter$!'; $SearchPatterns['default'][] = '!\.Template!'; # exclude all pages starting with "Template" QuestionWhat can you specify with the list-parameter for these markups? AnswerThe QuestionHow can I specify several groups to search (include search) and exclude others? Answer
$SearchPatterns['default'][] ='/^(Group1|Group2|Group3|Group4|M.*)\\./'; $SearchPatterns['default'][] ='!^Main\.!'; Result: limit search to articles in Group1 to Group4, and in groups starting with M but not in group Main.
Notes and CommentsSee AlsoContributors |