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

  1. add jump-box support -- if you enter an existing page name into the search box, PmWiki goes straight there
  2. 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)
  3. (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
  4. (optional) add a Publish button to Category? searches
  5. (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.

  1. download search.phpΔ and install it in the Cookbook/ directory
  2. 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>
  3. still in the template file, change Page last modified on to Page $ActDescription on (at this point, the text is English)
  4. add include_once("$FarmD/Cookbook/search.php"); to the local/config.php file
  5. create a PmWiki.SearchQuickReference file, like the one at http://intranet.affinity.co.nz/pmwiki2/index.php?n=PmWiki.SearchQuickReference
  6. test that everything works correctly by loading PmWiki and doing a search and a jump-to-page
  7. to take advantage of the publish features, download, install and test the latest version of PublishWikiTrail
  8. add $PublishSearch = true; to the local/config.php file above the statement that includes search.php
  9. 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
  10. test the search publish capability -- the search results page should have gained a Publish button
  11. 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

jr

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