Summary: New {$SearchQuery} variable and what you can do with it.
Version: 1.0
Prerequisites: PmWiki2
Status: beta
Maintainer: MateuszCzaplinski
Categories: Markup Searching

Questions answered by this recipe

  • Can I provide reader with a Create page link in search results (Site.Search) page, suggesting page name composed of his search terms?


Add the following line to your local/config.php file:

  $FmtPV['$SearchQuery'] = 'stripmagic(@$_REQUEST["q"])';  insecure, use HttpVariables instead.

Now, you can use the {$SearchQuery} markup to display the exact string user tried to find using Site.Search or the [Search] button.

Example usage

Thanks to the procedure shown above, you can modify the Site.Search page of your site to allow users to create new page, with name based on the terms they were looking for. To do that, edit the Site.Search page and below the line with: (:searchresults:) add following lines:

(:if ! equal "{$SearchQuery}" "" :)
'''If you want, you can also [[{$SearchQuery}|create a ''{$SearchQuery}'' page now]].'''


  • Todo: Test against special characters (also quotes) in user's search query.

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".


See Also


User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.