Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-07-22 10:14:15

iaian7
Plugin Author
From: US
Registered: 2006-12-05
Posts: 57
Website

an7_filter

an7_filter replaces text strings defined by a customizable array located in the script. Basically, this means you can finally include emoticons (smilies), 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 does make 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). The array is setup in a simple "text" => "replace" format and the wrap tags are reasonably concise; <txp:an7_filter>…content…</txp:an7_filter>.

Currently in alpha

Visit the site for more information and examples.


VFX artist, photographer, designer, CG generalist, and hobbyist web developer
My TXP sites: blog | reels | portfolios

Offline

#2 2008-04-27 23:50:14

alex9142
Member
Registered: 2008-03-17
Posts: 45

Re: an7_filter

Hi!

I am using your plugin, it works fine!
Now I am wondering if it’s possible to use it in the comments form. If so, how?

Thank you!

Offline

#3 2008-04-28 00:53:09

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: an7_filter

alex9142, you just wrap your comment messages with the an7_filter tags. whenever a commenter types in a symbol like :), the comment will show an image smiley for that symbol.


<txp:Ruhh />

Offline

#4 2008-04-28 03:26:38

alex9142
Member
Registered: 2008-03-17
Posts: 45

Re: an7_filter

Hi Ruhh!

Thank you for your help.
I will accept your solution.

Offline

#5 2008-06-15 10:58:41

Spot
Member
Registered: 2006-05-05
Posts: 39
Website

Re: an7_filter

Thanks for this plugin, works a treat.

Just thought it really should contain alt=”“ to validate, i.e:

‘imgb’ => ‘.png” alt=”“ class=“emoticon” /> ‘, // defines the second half of the image, including file format

Cheers


iMac 3.06 GHz 2 GB SDRAM
OSX 10.6.2

Offline

#6 2008-07-12 14:37:59

Mr. Smith
Member
From: Denmark
Registered: 2006-11-10
Posts: 56

Re: an7_filter

I’m trying to get this plugin to work, but I get an error message that I don’t really understand:

Parse error: syntax error, unexpected T_STRING, expecting ')' in /var/www/site.com/vf/textpattern/lib/txplib_misc.php(574) : eval()'d code on line 11 The above errors were caused by the plugin:an7_filter Tag error: <txp:an7_filter> -> Textpattern Warning: tag does not exist on line 983

I’m running Txp 4.0.6. It seems as if a closing parenthesis is missing, but where?

The plugin looks like this:

function an7_filter($atts, $thing=’‘) { global $thisarticle; global $thiscomment;
extract(lAtts(array( ‘imga’ => ‘ <img src=”/images/emoticons/’, // defines the first half of the image, sans filename ‘imgb’ => ‘.png” class=“emoticon” /> ‘, // defines the second half of the image, including file format
),$atts));

$replacements = array( // “bodystep” => “<span class=“red”>body</span>step”

$wrap = parse($thing);
$filtered = strtr($wrap, $replacements);
return $filtered;
}


Textpattern n00b

Offline

#7 2008-07-12 15:42:33

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: an7_filter

You’re missing a closing parenthesis on $replacements, and you’re also not escaping the quotes for bodystep (""foo"" needs to be "\"foo\"" or '"foo"').

$replacements = array(
	"bodystep" => '<span class="red">body</span>step',
);

Offline

#8 2008-07-12 16:41:05

Mr. Smith
Member
From: Denmark
Registered: 2006-11-10
Posts: 56

Re: an7_filter

Great, thanks!

It works fine as long as the word isn’t written with caps as Txp encloses these with <span class=“caps”> and thereby breaks this plugin which is kinda annoying.

But your adjustments helped and we’ll just have to write these words in lower case.


Textpattern n00b

Offline

#9 2008-07-12 16:43:27

Mr. Smith
Member
From: Denmark
Registered: 2006-11-10
Posts: 56

Re: an7_filter

Oops, guess that Txp’s <span class=“caps”> does not break the plugin, but it is the plugin that is case sensitive. My mistake. :-)


Textpattern n00b

Offline

#10 2008-07-17 20:10:53

iaian7
Plugin Author
From: US
Registered: 2006-12-05
Posts: 57
Website

Re: an7_filter

Spot wrote:

Thanks for this plugin, works a treat.
Just thought it really should contain alt=”“ to validate, i.e:
‘imgb’ => ‘.png” alt=”“ class=“emoticon” /> ‘,

Thanks for pointing that out!

I’ve just posted version 0.2.0 which fixes the image validating, and corrects the CSS to comply with plugin standards (using, by default, the plugin name to define styles for elements generated by the plugin).

Mr. Smith wrote:

…It works fine as long as the word isn’t written with caps…

The case sensitivity has not been addressed yet, as there is no native case-insensitive strtr function in PHP (that I’ve found). There is code to do it, but it’s not particularly short, and I haven’t picked through it yet.

JM and others, thanks for answering questions! I can’t always keep up with support questions, and really appreciate the help. :D

Last edited by iaian7 (2008-07-17 20:12:09)


VFX artist, photographer, designer, CG generalist, and hobbyist web developer
My TXP sites: blog | reels | portfolios

Offline

#11 2008-09-07 13:22:15

fuls
Member
Registered: 2005-11-16
Posts: 117
Website

Re: an7_filter

Hi,
I use this plugin on my comments and since I installed it all old comments are properly showing emoticons, but when I write a new comment it doesn’t work, emoticons are not showing.
Thanks for your help!

Offline

#12 2008-09-09 02:12:35

iaian7
Plugin Author
From: US
Registered: 2006-12-05
Posts: 57
Website

Re: an7_filter

fuls, that’s really, really weird. I’m not sure what could be causing it. Any more details you can add to the bug report? How exactly are you using it? Are you using any caching solutions or other plugins that might interfere?


VFX artist, photographer, designer, CG generalist, and hobbyist web developer
My TXP sites: blog | reels | portfolios

Offline

Board footer

Powered by FluxBB