PDA

View Full Version : automatic find and replace script




scem0
Dec 12, 2004, 09:18 PM
On many sites, scripts are implemented to go through the site and search through every document finding strings and replacing them with something different.

I'd like to find a script that does this to implement it on my website. And, I'm not just talking about manual replacement, I'm talking about automatic replacement. I could use Dreamweaver to do it by myself, but that would take forever, and I don't want to have to do it every week ><.

To get an example of what I mean, check out Wikipedia.

If you look at an article (example: http://en.wikipedia.org/wiki/PHP ) you can see that every time the word 'MySQL' is used, it links to the Wikipedia article of MySQL. Anytime 'MySQL' is in an article, it links to the 'MySQL' article. I'm sure they wrote their own script to do this, but I'm betting there is one for lazy people, somewhere.

I just want a script that will look through my website for the word 't-shirt' and will link that text to my t-shirt section of my site. Likewise for the text 'review', 'reviews', 'tshirt', 'tshirts', 't-shirts', etc.

I can't seem to find a script that does this.

Edit - Since I'm asking about this script, I might as well ask for another script I've been trying to find. I need a script to manage reviews at my website, which is a music review script. I was going to use 'FusionReview', but it isn't all that great. I've tried searching through hotscripts and sourceforge, but there are so many different scripts and it is hard to tell which ones are good, or which ones do exactly what you want them to do.

I basically want an article management system that supports rating the subject under discussion in the article (so things can be ordered according to rating, and whatnot). Any suggestions?

Thanks,

scem0



Rower_CPU
Dec 13, 2004, 12:10 AM
Check out preg_replace (http://us2.php.net/manual/en/function.preg-replace.php) - works pretty well once you get up to speed with regular expressions. The trick is to get all your web page content into a string the function can parse.

xelterran
Dec 13, 2004, 01:39 PM
use the strip_tags() function to get the content into a string, then pass that to preg_replace()

Rower_CPU
Dec 13, 2004, 02:43 PM
use the strip_tags() function to get the content into a string, then pass that to preg_replace()

Not sure if that's the best route since it'd lose any HTML he wanted in there.

The only thing that comes to mind is to use include/require for each content section and pass that into the string to process with preg_replace(). Kind of a lot of work to get everything set up that way, but it gives you more flexibility in the long run.

xelterran
Dec 13, 2004, 04:07 PM
hmm.. not sure what i was thinking there +_+

I found this though.. http://www.lehigh.edu/~www/make_www/IntDreamweaver/find.html

scem0
Dec 13, 2004, 04:45 PM
Yeah, I have dreamweaver, so I can already do it manually, but I'd like it to do it automatically to all pages on my site, including dynamically created webpages, like posts in a thread.

scem0

jeremy.king
Dec 13, 2004, 04:54 PM
The "technology" you are talking about (with automatic linking) is called a Wiki. Google and you will find a variety of options such as PHPWiki (http://sourceforge.net/projects/phpwiki/)

Rower_CPU
Dec 13, 2004, 05:44 PM
The "technology" you are talking about (with automatic linking) is called a Wiki. Google and you will find a variety of options such as PHPWiki (http://sourceforge.net/projects/phpwiki/)

That could work, too, if you want to change your whole backend.