Keyword replacement plugin

Creating and modifying plugins.
Post Reply
UncleG

Keyword replacement plugin

Post by UncleG »

Could someone tell me whether any of the existing plugins enable keyword replacement? For example I would like it when my post gets saved for a certain words to be matched and replaced with a hyperlink. Does any existing plugin enable this or if not is there any plugin that could be easily adapted to do this?

Getting really specific I'm imagining functionality along the these lines. If I was to have the string "[PHP]" in my post then the enclosed "PHP" would be matched in a regular expression and a look up would occur in an array of keywords. If the keyword is found then a replacement would occur so that "[PHP]" would be replaced with "<A href="http://www.php.net">PHP</a>".

Thanks
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Keyword replacement plugin

Post by garvinhicking »

Yes, this exists. It's called the "Content Rewrite" Event plugin. Please search the forums for a example configuration of it, I once posted it somewhere.

However there currently is no generic [....] replacement variable available. You could however do it like this:

[MANUAL_START]PHP[MANUAL_END]

and then rewrite [MANUAL_START] to '<a href="http://www.php.net">' and [MANUAL_END] to '</a>'. :-)

Regards
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gizmola
Regular
Posts: 37
Joined: Mon Oct 25, 2004 11:54 pm

Post by gizmola »

Like Garvin explained, the content_rewriter plugin does this. You do have to add an entry for each keyword, but once you have the first one worked out, it only takes a moment for each subsequent keyword.

Here's the rewrite I use, that happens to do exactly what you want:

Inside the plugin set the rewrite string to be: <a href="{to}">{from}</a>

Then add your entries, where Title is the keyword (PHP) and Description is your replacement (http://www.php.net/).

You hit save each time you add a new keyword/url pair.
Post Reply