Gossamer Forum
Home : Products : DBMan : Customization :

Emoticons in record view?

Quote Reply
Emoticons in record view?
I'm just wondering if anyone has done this and if so, how they did it?
I've had a few of my members requesting this feature and I'm not sure how I'd go about doing this, but I'm sure it's got to be possible to do.

Example:

Someone puts :) in a field and when the record is viewed, it'd show Smile. I've got 50+ fields, so this would need to be able to do it on all of them. Any ideas?
Thanks!
Quote Reply
Re: [shann123] Emoticons in record view? In reply to
Overall, the thing you would need to do is define your smilies and then do some nested loops. The first loop would go through all of your fields and the one inside it would go through all of your smilies and do the substitution.

I'm not real good on regular expressions, and especially with using variables in them, so I can't give you much more than that, but at least it's a direction to go in.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [shann123] Emoticons in record view? In reply to
A quick and dirty solution would be to add the following for each field in your display (assuming you aren't using auto-generate).

if ($rec{'Name'} =~ /\:\)/) {print qq|<IMG SRC="./smiley.gif">|;}
if ($rec{'Name'} =~ /\;\)/) {print qq|<IMG SRC="./wink-smiley.gif">|;}

However, there's gotta be a better way... are you sure you want to allow smileys on all fields and not just perhaps on a certain field at the top of the record or something?
Quote Reply
Re: [Watts] Emoticons in record view? In reply to
Maybe not all fields, but it'd be the majority of them. It's for personal profiles and members would like to be able to add smilies.
I'll give your suggestion a try sometime in the next day or two and let ya know how it goes. Yeah.. there's gotta be a better way, but at least that's a start. Wink
Quote Reply
Re: [shann123] Emoticons in record view? In reply to
I tried that out and it worked, to a point. It didn't replace the :), but it did add an emote if that was in the field.
Quote Reply
Re: [shann123] Emoticons in record view? In reply to
I was interested to see if I could get this to work. I couldn't. :-) My thought was to have something like this:

Define each smiley like $smilie{filename} = emoticon; so you would have something like

$smilie{smile} = ":)";
$smilie{frown} = ":(";
$smilie{wink} = ";)";

And then using the following code:

Code:

foreach $col (keys %rec) {
foreach $file (keys %smilie) {
$graphic = "<img url/to/smilies/dir/$file.gif>";
$rec{$col} =~ s/$smilie{$file}/$graphic/g;
}
}


But it doesn't work. The reason it doesn't work is because of the nature of smilies -- the fact that they use ) and (. The substitution causes the regular expression to be interpreted as though they are really parentheses and not just characters. I tried adding \ before them and it still didn't work.

What did work is to use words to define the smilies. Here's a little script that worked just as I wanted it to:

Code:

$rec{'Name'} = "Fred smile";
$rec{'Address'} = "Bedrock frown";
$smilies{smile} = "smile";
$smilies{frown} = "frown";
$smilies{wink} = "wink";
foreach $col (sort keys %rec) {
foreach $file (sort keys %smilies) {
$graphic = "<img url/to/smilies/dir/$file.gif>";
$rec{$col} =~ s/$smilies{$file}/$graphic/;
}
}


That gets you what you want, but there's two problems. One is that people are used to using smilies and not typing out the name of the smilie. The other is that you wouldn't be able to use the word anywhere else.

But maybe this will help to point you or someone else in the right direction. :-)


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Emoticons in record view? In reply to
I totally spaced out on shann123 wanted... It's been done before, I'll have to dig it out. One thing you'll want to consider is adding some kind of "qualifier" - kinda like GT does here with the colors [red.] Red [/red.]
by adding the brackets.

So something like:
$smilies{wink} = "**wink**";
might make it a little "safer" for people to use the word "wink" without it being misinterpreted.

I'll see if I can find the post I remember seeing....
Quote Reply
Re: [shann123] Emoticons in record view? In reply to
I think I have what you want, sorta. This works:

Code:

$smilies{smile} = ":smile:";
$smilies{frown} = ":frown:";
$smilies{wink} = ":wink:";
foreach $col (sort keys %rec) {
foreach $file (sort keys %smilies) {
$graphic = "<img url/to/smilies/dir/$file.gif>";
$rec{$col} =~ s/$smilies{$file}/$graphic/g;
}
}
foreach $col (sort keys %rec) {
print $rec{$col} . "\n";
}


It's not really smilies, but you can get the graphics where you want them. I tried everything I could think of to get the actual similies -- :-) :-( ;-) -- to work, but it would always try to interpret the characters.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.

Last edited by:

JPDeni: May 25, 2005, 8:41 PM
Quote Reply
Re: [JPDeni] Emoticons in record view? In reply to
Thank you very much JPD! I'll give this a try later and let ya know how it comes out. Smile
Thanks again!