Gossamer Forum
Home : Products : DBMan : Customization :

smiles mod

Quote Reply
smiles mod
hi i wonde if we can add a smile mod ,such as if i want smile face icon to be post i just type :-)
But not add to a new field.


Please Excuse me for my poor knoledge of PERL
Regards,
Act.
Quote Reply
Re: smiles mod In reply to
This should be easy.

In default.cfg add the following:
Code:
# URL to the directory with the smile images:
$smile_url = 'http://www.myserver.com/images/smiles/';

# Add each smile as 'smile-code','image':
@smiles = (
':)','smile.gif',
';)','wink.gif',
':(','sad.gif'
);
Then, at the top of html_record, under the line my %rec = @_;, add the following:
Code:
for ($i = 0; $i < scalar(@smiles); $i = $i + 2) {
$rec{'Description'} =~ s/\Q$smiles[$i]\E/<img src="$smile_url$smiles[$i+1]">/g;
}
You'll have to customize $rec{'Description'} to the field you want to make the smiles in.

I haven't tested the code, so let me know if it doesn't work.

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: smiles mod In reply to
Hi,

Do you not need to escape those smilies?


Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: smiles mod In reply to
Hi Mark ,thank you , but it's not work.
i see what i typed,it 's not turn to smile gif.
I have changed the $rec{'Description'} to the field you want to make the smiles in.

And i ever added code
$value =~ s/<([^>]|\n)*>//g; # Remove HTML
in sub parse_form but removed it before add you modufy (i add this code 'coz a user type a html code ;<bgsound="http://www.geocities.com/mhuky/240.mid" autostart="true"> and it disorder my recode table.)


but it is not success.


Please Excuse me for my poor knoledge of PERL
Regards,
Act.
Quote Reply
Re: smiles mod In reply to
In Reply To:
Hi Mark ,thank you , but it's not work.
I've found the problem and changed the code above.

All you need to do is take out each "my".

eg: my $smile_url = ....

This time I tested it Smile

In Reply To:
Do you not need to escape those smilies?
Nope, because they're in quotes. Then the \Q and \E "escape" the string in the re so it is not executed.

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: smiles mod In reply to
---------------------------------------------------------------
Then, at the top of html_record, under the line my %rec = @_;, add the following:


for ($i = 0; $i < scalar(@smiles); $i = $i + 2) { $rec{'Description'} =~ s/\Q$smiles[$i]\E/<img src="$smile_url$smiles[$i+1]">/g;}
---------------------------------------------------------------
Hi, sorry Mark, i never tell you about the above script.I just see that code above will take every short record send to the newest long record.
So,I try take the code off and test it and it work ok,each short link to its record. I wonder what was wrong with it.Please help me .



Please Excuse me for my poor knoledge of PERL
Regards,
Act.
Quote Reply
Re: smiles mod In reply to
If you're using the shot/long view mod, then you will also need to include the code in html_record_long

As with before, make sure you put it under the line my %rec = @_;

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: smiles mod In reply to
Soory for my bad english,but i mean
if i put your code in .html the recodr list page will has a mistake.When i click on short html to see the long html Instead of sending to its record ,it will send to a record.This is
the url that will fix for each record;
me.cgi?db=default&uid=default&sb=0&so=descend&view_records=1&ID=*&nh=2&mh=1

nh value fix for all record url so it take us to a fix url not the record long html url.


Please Excuse me for my poor knoledge of PERL
Regards,
Act.