an7_filter
iaian7 » code » txp John Einselen, 22.07.07 (updated 15.06.11)an7_filter replaces text strings defined by a customizable array. In short, this lets you insert emoticons, instant messenger style! It can also be used for undesirable language filtering or keyword link insertion.
While an7_filter does not automate this process entirely, it makes it fairly easy. Used as a wrap tag, it will filter the contained text using an array specified in the plugin (the default is setup for emoticon replacement).
example
plugin settings:
... $imga = '<img src="/images/emoticons/'; $imgb = '.png" class="emoticon" />'; $replacements = array( "text" => "****", ": )" => $imga."smile".$imgb, ...
textpattern template:
... <txp:an7_filter><txp:body /></txp:an7_filter> ...
raw text:
this text is being filtered. : )
final result:
this **** is being filtered.
Please note that the plugin is currently case-sensitive.
plugin options
an7_filter comes ready for use as an emoticon plugin. It’s suggested that you wrap <txp:body />
, <txp:excerpt />
, <txp:message />
, <txp:search_result_excerpt />
, and similar tags, as these are the most common places to find replaceable text. I’m not sure about the impact on the server if one were to try to wrapping an entire page, it might not be the best idea. The listed tags should be sufficient, and keep PHP processing time to a minimum.
To avoid some specific code issues, I’ve added a space before each text string. This prevents links from being corrupted by :/
(short variation of :undecided:
), but still allows a string of emoticons separated only by single spaces.
>:o :[ 8) :’( :! :( :o :D :angry: :blush: :cool: :cry: :eeeih: :frown: :gasp: :grin:
0:) :* :P :$ :x :) :/ :halo: :kiss: :laugh: :money: :sealed: :smile: :undecided:
(this is a partial list, there are other variations for many of the emoticons, and of course this is entirely customizable)
For emoticon images, you must edit the 'imga'
and 'imgb'
attributes to reflect your file structure and image types. For other text replacement features, the array can be edited to handle just about anything.
download
This plugin is currently in beta
1 (version 0.2.0)
installation
Copy the plugin text into your textpattern “install plugin” field and click “upload”. Enable the plugin and edit the source to customize the replacement array ("text" => "replacement";
).
If you want to use emoticons, find a good icon pack and upload it to your images folder (for organization, probably under a “emoticons” subfolder). I don’t have an “official” pack yet, but once the plugin goes live I hope to have a default installation ready.
Edit your page or article templates by wrapping desired tags with <txp:an7_filter>
and </txp:an7_filter>
. Save any changes, and that should be it!
version history
v0.2.0
— beta, added simple documentation and correctly validating image code
v0.1.0
— alpha, undergoing testing
help and support
For questions and support, please visit the an7_filter post in the Textpattern Forums.
credits
The template from thresholdstate.com was helpful as always. <3
Hi!
I installd your plugin today and seems to be very cool. Unhappilly, it is returning an error message:
Parse error: syntax error, unexpected ‘;’, expecting ‘)’ in /home/mosapyr/public_html/textpattern/lib/txplib_misc.php(574) : eval()‘d code on line 27
Os erros acima descritos foram causados pelo plugin:an7_filter
Is there anything else that I can do?
Thank you,
Alexandre.
Brilliant plugin, thank you!