FoxTextReplace
Questions answered by this recipe
Description
This recipe uses a Fox form to let you replace text strings on multiple pages.
PowerTools is needed to let the user enter target pages with wiki wildcards (see PowerTools#plist for details).
Create a page with this Fox form:
(:foxmessage:) (:fox frm foxaction=replace put=all target='{$$(plist {$$pat})}' foxtemplate="{$$new}" mark='{$$mk}':) ||table width=600px || Replace text string:||(:input text mk size=40:) || || With this string:||(:input text new size=40:) || || On Target Pages:||(:input text pat size=40:) || || ||(:input submit post 'Replace Now':) || Notes: you can specify several target pages (space delimited),\\ or use wiki wildcards (* and ?) in target page names.\\ Example:\\ '''Test.*''' to replace string on all pages in ''Test'' group. (:foxend frm:)
The form will look somewhat like this (non-functional example):
Replace text string: | |
With this string: | |
On Target Pages: | |
or use wiki wildcards (* and ?) in target page names.
Example:
Test.* to replace string on all pages in Test group.
The target field accepts wiki wildcard target names. Make sure not too many pages are targeted, because otherwise Fox will be stopped before ending with an PHP timeout error.
Make sure Fox is permitted to perform a replace foxaction on the target pages. You may need to set $FoxPagePermissions for this in config.php (see Fox#security). Be aware of the security risks of allowing such action.
All occurences of the text string found will be replaced. If you only wish to replace the first occurence in a page, you should replace in the form put=all with put=string
Notes
Release Notes
- 2008-12-08: initial release
See Also
Contributors
Comments
See discussion at FoxTextReplace-Talk
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.