Cookbook /
SearchQueryVariable
Summary: New
{$SearchQuery}
variable and what you can do with it.Version: 1.0
Prerequisites: PmWiki2
Status: beta
Maintainer: MateuszCzaplinski
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?
Description
Add the following line to your local/config.php
file:
insecure, use HttpVariables instead.$FmtPV
['$SearchQuery'] = 'stripmagic(@$_REQUEST["q"])';
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]].''' (:ifend:)
Notes
- Todo: Test against special characters (also quotes) in user's search query.
Release Notes
- 2006-12-21 - v1.0 - initial version, by MateuszCzaplinski
Comments
See Also
- Cookbook:Excerpts - the
{$SearchQuery}
variable can be used as a search term for the(:excerpts:)
markup. - Cookbook:SortByScore
Contributors
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.