Cookbook /
SearchExtensions
Summary: Ways to make searches more useful
Version:
Prerequisites:
- This recipe was last tested on PmWiki version: 2beta26
- This recipe requires at least PmWiki version: 2beta1 and (if you want the publishing features) PublishWikiTrail
- version 2beta35 requires a patch to scripts/pagelist.php (described below)
- version 2beta37 includes the patch to pagelist -- use the search2.phpΔ recipe
Status:
Maintainer: jr
Categories: Searching
Question
How can we make searches more useful?
Answer
- add jump-box support -- if you enter an existing page name into the search box, PmWiki goes straight there
- add an action=search that
- displays the search results in the current page location (instead of taking a searcher to the Main.SearchWiki page)
- displays a PmWiki.SearchQuickReference page, if it exists
- separates the searched for text into needle (search term(s)) and haystack (group)
- (optional) add a Publish button to the search results, allowing a searcher to select pages of interest and display the content in a form suitable for printing
- (optional) add a Publish button to Category? searches
- (search2.phpΔ only) add an action=backlinks that lists references to the current page -- try adding this action to the page name in a template
Notes and Comments
Please note. The PublishPDF library includes the SearchExtensions recipe.
- download search.phpΔ and install it in the Cookbook/ directory
- place
$SearchTagFmt
in your template file at the point you want the search box to go (in the default PmWiki template, replace the text between <div id='wikihead'> and </div> - still in the template file, change
Page last modified on
toPage $ActDescription on
(at this point, the text is English) - add
include_once("$FarmD/Cookbook/search.php");
to the local/config.php file - create a PmWiki.SearchQuickReference file, like the one at http://intranet.affinity.co.nz/pmwiki2/index.php?n=PmWiki.SearchQuickReference
- test that everything works correctly by loading PmWiki and doing a search and a jump-to-page
- to take advantage of the publish features, download, install and test the latest version of PublishWikiTrail
- add
$PublishSearch = true;
to the local/config.php file above the statement that includes search.php - if you want all 'search found' pages to be checked, add
$PublishSearchChecked = true;
to the local/config.php file above the statement that includes search.php - test the search publish capability -- the search results page should have gained a Publish button
- if your Category.GroupFooter contains
(:pagelist 'Category.{$Name}' list=normal:)
, category pages should also have gained a Publish button
History
- 27-Jul-05 possible fix for farm-based installation (thanks to K.A.Bouton)
See Also
PublishWikiTrail
Contributors
Discussion
Problem
pmwiki-2.0.beta34/5. doesn't like your good job ! :
"Warning: join() [function.join]: Bad arguments. in .../cookbook/search.php on line 89
Warning: Invalid argument supplied for foreach() in .../cookbook/search.php on line 90 "
I don't know php, I can't help you ! Thanks . Pierre79
The problem lies in the updated FmtPageList function, which defines the needle (search incl and search excl) and haystack (group) after calling the fmtfn. This breaks the SearchExtensions. The fix is to move the following 3 statements above the call to fmtfn:
$GLOBALS['SearchIncl'] = array_merge((array)@$opt[''], (array)@$opt['+']); $GLOBALS['SearchExcl'] = array_merge((array)$opt['-']); $GLOBALS['SearchGroup'] = @$opt['group'];
I'll ask Patrick about it. A couple of changes to search.php are also required. jr