- Create Account

Smileys

Forums > Forum Development > Smileys
Author
Message

1) Dax Group: Guests
IP: 210.212.--.--
I'm not at all experienced with Perl.

Is there any way to duplicate the [URL] code in the forum.pl file to replace ":)" with "smile.gif"?

I  get some hideous errors when I tried to code that in, as I can't put a ")".

Thanks

2) Angus Turnbull Group: Guests
IP: 210.54.--.--
You're on the right track -- just make sure you escape any special characters, so match and replace :\( as the backslash means "treat the next character as a literal character rather than a special meaning".

If you replace them with the appropriate <img src> tag smiley support should be easy.

Good luck - Angus.

3) Joao Group: Guests
IP: 213.13.--.--
Yes, it would be a great feature. Does any one knows how to do it? making this ":P" be replace by "/images/smile2.gif" ? please insert here the code if possible, and where it should be insert in the script. I have made some changes in forum (translating it from English to Portuguese) but I don't see how to do this.

4) Angus Turnbull Group: Moderators
Posts: 4042 Joined: 7 Dec 2003 Location: New Zealand IP: 210.54.--.--
Well, look in the post formatting function in forum.pl.

Put in a substitution regular expression there that matches :P and replaces with <img>. That should do it.

- Angus.

5) Joao Group: Guests
IP: 81.193.--.--
I've found:
 # Match  and write IMG tag.
 $tmp =~ s/\[img\]([^"\s<>\]\[]+[^"\s<>\]\[\.\,\(\)])(\[\/img\])?/<img  src ="$1" \/>/ig;

but  I don't understand here to insert image link (ie.: http://myserver.tld/images/piture.jpg) and the shourt cut... (ie.: :P or  :D)

If some one could give me help I would apreciate :P

6) Angus Turnbull Group: Moderators
Posts: 4042 Joined: 7 Dec 2003 Location: New Zealand IP: 203.96.--.--
Find a Perl tutorial ;). Something like this should do:

$tmp =~ s/\:P/<img  src ="smiley.gif" \/>/ig;

The  forward slashes separate the match and replace halves of the regex, and any special characters are escaped with backslashes. "ig" on the end means case-insensitive global match.

- Angus.

7) Joao Group: Guests
IP: 81.193.--.--
Thanks Angus for your help :D

8) Ryan Group: Guests
IP: 62.53.--.--
I tried putting the smilies in but I just cant seem to get them to work. I did exactly as above.

9) Joao Group: Guests
IP: 81.193.--.--
Dear Ryan, find in forum.pl: " # Match [ img  ]picture.gif and write IMG tag. " the "[" "]" between "picture.gif" is more near... but would appear in this message as an not existing image.. in forum they are more near!... then put in this way:
$tmp =~ s/\:\)/<img src ="http\:\/\/www\.yourdomain\.com\/images\/smile1.jpg" \/>/ig;

making this :) will appear the image at your server with the name: smile1.jpg . As you are seeing after "$tmp =~ s/\" its ":\)" an not ":)" ... be sure to put an "\" before ")", "(", "$"  ... our you will get an error and the script will not work. If you have problems you my have insert something like this: "|", ")", "(",  "$", "%" or someting like this... try putting an "\" before this special characters.. if it does not solved the problem simply remove the special character and try another short cut.

Post a Reply:

You are not logged in, and will be posting anonymously as a guest. If you want to post using an account, please login at the top of this page.