Search / Replace utility

October 21st, 2013

Search / Replace utilityThis a Joomla 1.5, 2.5, 3.0 and 3.1 native system plugin allow to search and replace any content present in a page.

You can use basic search/replace and also regular expresion Search/Replace.

The Search/Replace statement can also processed from an external file on the disk and not only from parameters in the plugin settings. This feature can be usefull when combined with Jms Multi Sites extension to have specific Search/Replace pattern depending on a website.

As this is a system plugin, you can Search and Replace whatever including information in the html header and not only in the content of an article.

This can be used for example to replace some keywords that could be placed in “shared articles” and that will be replaced by their specific values in a given website using this Search/Replace plugin.

You can also apply the Search/Replace on the URL content and modify the parameters received by Joomla.

You can for example use a basic Search/Replace like:

[COMPANY] = This is my company

[DEALER_NAME] = This is the dealer name

But also use Regular expression Search/Replace when starting the “Search” pattern with a tild (~) like hereafter

~#\[COMPANY\]#i = This is my company

The list of Search/Replace can also be provided from external files.
You can provide 2 external files with the Search/Replace patterns.
For example you could use :

* file #1 = {root}/tmp/searchreplace.php

* file #2 = {root}/tmp/searchreplace{site_id}.php

As you can see, some keywords can be used in the file names.

* {root} = the document root directory if the website
* {site_id} = the Multisites slave site ID.

In this sample, we have use a PHP file extension to allow protect the content of this file.
Here it is a sample of file content