Page 1 of 2

Adding / Changing Emoticons

Posted: Fri Feb 23, 2007 4:26 pm
by NimNim
Hiya,

I would like to know how to change the emoticons that come as standard with Serendipity. I have found the folder in which they reside, and could easily save different emoticons with the current names, and replace them that way. However, I would prefer to use some animated gifs (such as the ones on this board).

I assume I can do this by reassociating the instructive text ie : ) (without the space) to my gif files rather than the current pngs. As such, I need to know which file gives the instruction that links the text to the emoticon. Does anyone know which file that is?

Also, can I simply add more instructions and emoticons, so that I can have more emoticons automatically inserted into my journal?

I hope I'm making sense :|

Thank you,

Nim

Re: Adding / Changing Emoticons

Posted: Fri Feb 23, 2007 4:41 pm
by garvinhicking
Hi!

Have a look here: http://www.s9y.org/44.html#A15

HTH,
Garvin

Posted: Sat Feb 24, 2007 10:28 am
by NimNim
Yes. I don't have a clue what it's going on about!

Posted: Mon Feb 26, 2007 8:44 am
by garvinhicking
Hi!

What's your problem exactly? The URL tells you where you can change the emoticon classes/image files?!

Best regards,
Garvin

Posted: Thu Mar 01, 2007 1:57 pm
by NimNim
Hi,

Sorry .. I've been away.

My problem is probably quite simply that I'm thick. I understand html, and I understand CSS. I don't understand PHP.

Basically, that page just looks to me like it's an explanation of what each tag is .. rather than instructing me on how to ammend them or anything.

The only part on the page I can find that is related to emoticons is this:

.emoticon
A smily, created by the Emoticon Markup Event Plugin.

I already knew what an emoticon was. I assumed it was a CSS instruction .. but doing a search of the CSS document for the word 'emoticon' brings back no results.

So, if it isn't a CSS instruction, then what is it? I can only guess that it's PHP .. in which case I don't know which PHP file it's in. I can't find it in any of the main PHP files or the files attributed to the template I'm using.

And now having written all of that. I see that it says 'Emoticon Markup Event Plugin' ... is that something I need .. or something I should be able to find and alter??

Man, I'm confused.

Nim

Posted: Thu Mar 01, 2007 2:02 pm
by NimNim
Hehehe :oops: Found it!!!!

Basically it's this:

"\:'\(" => serendipity_getTemplateFile('img/emoticons/cry.'.$ext),

'\:\-?\)' => serendipity_getTemplateFile('img/emoticons/smile.'.$ext),

'\:\|' => serendipity_getTemplateFile('img/emoticons/normal.'.$ext),

'\:\-?O' => serendipity_getTemplateFile('img/emoticons/eek.'.$ext),

'\:\-?\(' => serendipity_getTemplateFile('img/emoticons/sad.'.$ext),

'8\-?\)' => serendipity_getTemplateFile('img/emoticons/cool.'.$ext),

'\:\-?D' => serendipity_getTemplateFile('img/emoticons/laugh.'.$ext),

'\:\-?P' => serendipity_getTemplateFile('img/emoticons/tongue.'.$ext),

';\-?\)' => serendipity_getTemplateFile('img/emoticons/wink.'.$ext),



Soooo .. I have a new question :)
Is 'serendipity_getTemplateFile' an instruction or a file that I need to find?

Nim

Posted: Thu Mar 01, 2007 3:01 pm
by garvinhicking
Hi!

If you read the full text of the page I gave you, you'll see this statement:
To customize smilies with individual images from a theme, you can
create the file 'emoticons.inc.php' inside this template directory
and use an array like this:
So that means, create a file emoticions.inc.php inside the directory of the template you are currently using. Copy+paste the code that is on the http://www.s9y.org/44.html#A15 page, and then adapt that code so that it contains your smilies you want to use.

You only needto look at the serendipity_event_emoticate.php file to see what default emoticons are set there. With the config.inc.php file you override those!

serendipity_getTemplateFile is a PHP function call that returns the full path to a file inside your current template directory to the subdirectory of the 'img/emoticons/' path.

Maybe you can try some more, I'm sure it'll al become obvious to you. If you still have problems, report back here - once I'm finished with my flu I might be able to give more precise help.

Regards,
Garvin

Posted: Thu Mar 01, 2007 7:22 pm
by NimNim
Ooo, I'm sorry you have flu. If you can, take some Glucosamine, and stay warm and fed properly :)

I'll give the emoticons a try now. I didn't see that bit on the page .. but it's a very long page!!!!

Nim

Posted: Fri Mar 02, 2007 1:47 am
by NimNim
Ummmm ... my journal seems to have vanished.

Ok .. let me (nb thickie) get this straight:

I create a file called 'emoticions.inc.php' which I upload to my template folder.

In that php file I use the code from the url you gave me to refer to my own emoticon gifs ... which I upload to the images folder within my template folder?

Coz that's what I've done. And my journal's gone splat. Well .. blank page anyway.

I'm a nuisance aren't I :oops:

Nim

Posted: Fri Mar 02, 2007 1:55 am
by NimNim
Deleting emoticons.inc.php from the server restores the journal.
I created it in Notepad.
Was I supposed to put a reference to emoticons.inc.php in another file somewhere?
Where does the config.inc.php file come into it?

Nim

Posted: Fri Mar 02, 2007 1:57 am
by garvinhicking
Hi!

If your page vanishes it means the emoticons.inc.php file has a PHP parse error, caused by invalid statementsorsomething like that! Like if you keep "..." in the code but that's not a valid php statement. Or if you have an extra "," somewherein the code. Or if you're missing a ";" after a statement...

An editor with php syntax highlighting might show you where the error within that file lies

Bestregards,
Garvin

Posted: Fri Mar 02, 2007 5:42 am
by judebert
You've almost got it! The fact that your page went blank indicates that Serendipity read the file, but there was an error. The error was low-level: a PHP error, not a Serendipity error (we print something out when Serendipity detects an error).

To be absolutely precise: create that emoticons.inc.php file again, in the same place. Make sure it has exactly these contents:

Code: Select all

<?php
$serendipity['custom_emoticons'] = array(
  ":'(" => serendipity_getTemplateFile('img/cry_smile.gif'),
  ':-)' => serendipity_getTemplateFile('img/regular_smile.gif'),
  ':-O' => serendipity_getTemplateFile('img/embaressed_smile.gif'),
  ':O' => serendipity_getTemplateFile('img/embaressed_smile.gif')
);
?>


That's everything from the "<?php" to the "?>". ("Exactly these contents" doesn't include the "code" tag. In fact, if you put anything before the "<?php", it'll give you the blank screen again. Stupid formatting.)

Then create an img/ directory in your template directory, if it doesn't already have one. Put your emoticon images in there.

Then change the "cry_smile.gif" and other file names to match your emoticon file names.

Everything should now work as expected.

If you want to define some additional emoticons, you can add them after the ':O' definition. Notice that the entries are formed like "a, b, c, d", so if you want to add an "e", you need a comma after d. So when you add extra emoticons, you ensure there's a comma after the previous line, copy a line, and make any changes.

Posted: Fri Mar 02, 2007 10:22 am
by NimNim
YAY!!!!!! *kiss* *kiss* *kiss* *kiss* *kiss* *kiss*

It hasn't died!!!

Some of the images for the smilies aren't working, but I'll check whether that's coz of case sensitivity or incorrect file extensions etc.

Thank you both for your help :)

(Incidentally, the problem was that I'd literally copied

Code: Select all

 and 
into the file, and the '...' coz I'm thick).

Nim

Posted: Fri Mar 02, 2007 10:30 am
by NimNim
One last question. I notice that when I put a word inbetween two asterisks it makes the word bold.

Well, I don't want it to do that .. would that be where I use the \ or / function? (Can't remember which one it is).

On my emoticon.inc.php I have specified that *waves* be a particular emoticon. It's still coming up as waves instead though.

Any ideas?

Nim

Posted: Fri Mar 02, 2007 11:34 am
by garvinhicking
Hi!

The plugin "Serendipity Markup" is responsible for doing those asterisk-transformations, so you can remove that event plugin!

HTH,
Garvin