Lazyman smileys (embedded)

| tutorials | | Comments (12) | TrackBacks (22)

I really liked the script that Jennifer put together for the Lazyman smileys (pop up version), but Melissa and I wanted the smileys to appear on the page next to the comment box instead of in a pop up window.

Don't forget, if you've upgraded to MovableType 2.6 or higher, you'll need to tweak your Sanitize settings so the images will display.

The smiles come from Jason's and were discovered by Melissa.

Note: I still use MTMacros because I want to be able to convert :) to the image version.

Updates:
» You must be running PHP in your blog (or you can PHP-parse your HTML files, but you get to look up how to do that yourself).
» The easiest way to implement these smileys is to use the Individual Entry Archives as your comment entry form instead of using the comment popup window. This is easy to change. You'd swap out the following:

<a href="<$MTCGIPath$><$MTCommentScript$>?entry_id=<$MTEntryID$>" onclick="OpenComments(this.href); return false">Comments (<$MTEntryCommentCount$>wink</a>

for:

<a href="<$MTEntryLink$>#comments">Comments (<$MTEntryCommentCount$>wink</a>

If you're really stuck on the comment popup, send me email and I'll write up a workaround.

1) Take the following code and paste it into a new Index Template (text version for download):

<?
$smiliepath = "/images/smiles/";
$serverPathToSmilies = "/path/to/your/images/smiles/";
?>
<script language="javascript">
<!--
function writeImgTag(code, w, h)
{
   var cache = document.comments_form.text.value;
   this.code = code;
   document.comments_form.text.value = cache + " <img src='<? echo $smiliepath; ?>" + code + "' width='" + w + "' height='" + h + "'> ";
   document.comments_form.text.focus();
}
//-->
</script>
<?php
$cellcount=0;
if ($handle = opendir($serverPathToSmilies)) {
   while (false !== ($file = readdir($handle))) {
      $retVal[count($retVal)] = $file;
   }
   closedir($handle);

   sort($retVal);

   for ($xx=0; $xx < count($retVal); $xx++) {
      if (substr($retVal[$xx], -4) == ".gif") {
         $size = getimagesize($serverPathToSmilies . $retVal[$xx]);
         $name = substr($retVal[$xx],0,(strpos($retVal[$xx],".gif")));
         $width = $size[0];
         $height = $size[1];

         echo "<img onClick=\"writeImgTag('".$retVal[$xx]."','".$width."','".$height."')\" src=\"".$smiliepath.$retVal[$xx]."\" width=\"".$width."\" height=\"".$height."\" alt=\"".$name."\" title=\"".$name."\" border=0> ";

      }
   }
}
?>
<br /><br />

Fix the following: $smiliepath (This is the URL to your images; you could put http://www.yourserver.com/images/smiles/ if you want to have the full path for your images), $serverPathToSmilies (this is the directory on the server where the smileys live).

Also, make sure that your comment form is called "comment_form" or rename it in the code above. Ditto for "text" (this is the text box for comments).

2) Save this in the same directory that your images are in. On my server, this is images/smileys/index2.php (index.php is where I was playing with the pop up version).

3) Because I removed the table tags from the original PHP code, the images will "float" nicely on your page. Add the following to your comment form (either in your comment pop up windows or in the Individual Entry Archives template):

<?php include("/PATH/TO/images/smiles/index2.php"); ?>

4) Rebuild your site.

5) Test and have fun!

12 Comments

Sonia said:

Thanks for this.. I've really wanted to add smilies *S*

Jason said:

Wow! That's a lot of smilies! All on one page, but where's the guitarist? He's my favorite.

Melissa said:

Thank you for the credit link girlie. You're always so good at crediting your sources.

~Angelfire~ said:

I can't get the code to work!! I've tried everything!! I'm wondering if it's 'cause of the php include code...i dunno if i'm doing it right.
is this ok? (P.S. I do have a ""

Please help! I've been working on this for a couple of hours now but i can't figure it out!!

BeerMary said:

Has anyone done this successfully with pmachine? I would love to do it, but can't.

Beatriz said:

I would love to know how do you make it work in the comments pop-up page, since it's a .cgi extension.

If you have solution, please let us know

Lisa said:

Beatriz: You don't. You can do the lazyman popup though. Sorry!

Bailey torkelson said:

cute smileys!!!

Jenni said:

I implemented the script and the smilies show up in my individual entry pages, but they don't show up in the actual comments. Any clue why? I've checked and can't seem to find what could be causing it.

Jenni said:

Does anyone have problems with this messing up their site when viewed with Mozilla? I'm trying to figure out if it's the smilies or the live text preview that I just implemented. Whatever it is, something is making page all wonky in Mozilla.

Mopet said:

Why do not I see me posts???

22 TrackBacks

Listed below are links to blogs that reference this entry: Lazyman smileys (embedded).

TrackBack URL for this entry: http://www.beantowngeek.com/cgi-bin/mt/mt-pong.cgi/160

» Lazyman's smilies... from scriptygoddess.com

One of the reasons I had taken smilies off my site was because I didn't like the look of all Read More

» My Smilies from kadyellebee

A few notes on my smilies and how I set them up. I had bigger smilies before that were purple Read More

» More Hacks for today from The After Hours Pub

Stuff for today: 1. Embed the smilies. I had a problem with this yesterday, and that's because I didn't put the absolute path in my archive template. Here is the parsing error: Warning: open_basedir restriction in effect. File is in... Read More

» Smilies Make My World Go Round from anything but ordinary

I spent some time today editing a few smilies that I found and making them more uniform. I created a spork smiley: ... for my posse. I also tweaked a hat and a beanie smiley I found: /images/lazymans/flowerhat.gif" alt="flowerhat" />... Read More

» Smilies Make My World Go Round from anything but ordinary

I spent some time today editing a few smilies that I found and making them more uniform. I created a spork smiley: /images/lazymans/spork.gif" alt="spork" /> ... for my posse. I also tweaked a hat and a beanie smiley I found:... Read More

» Spend a morning in my shoes from The After Hours Pub

I say, ok, smileys NOW! Gotta start from scratch, so I go over to the MT website to get into the support forums. But I never make it that far. The latest entry on MT is that they've been nominated... Read More

» Spend a morning in my shoes from The After Hours Pub

I say, ok, smileys NOW! Gotta start from scratch, so I go over to the MT website to get into the support forums. But I never make it that far. The latest entry on MT is that they've been nominated... Read More

» Plugins! from Random Ramblings

Have added some more plugins to the site, as well as utilising all the smilies I have in my smilies directory. Thanks again to Lisa, Gal of Unix ! In other news the weather has been great and i've rediscovered our conservatory for that all important Re... Read More

» Smilies Test from Zachhale.com

I finally fell in and added smilies to my site. I am sorry though that I cannot have a comment pop-up window any longer. You will have to comment in... Read More

» Too much eyestrain? from Say What?

Added some clickable smilies to the comments page. Let me know what you think of em. I guess if I'm not careful, I may end up with too much stuff on my page. Nobody minds waiting for it, right? heh... Read More

ˬÌä¼Ô¤Î¥³¥á¥ó¥ÈÅê¹Æ¥Õ¥©¡¼¥à¤Ç¥¹¥Þ¥¤¥ê¡¼²èÁü¤ò»È¤¨¤ë¤è¤¦¤Ë¤·¤Æ¤ß¤Þ¤·¤¿¡£ º£²ó¤Î²þ¤¤Ë¤âȾÆü¤Û¤É¤«¤«¤Ã¤Æ¤·¤Þ¤¤¤Þ¤·¤¿¤¬¡£ ¥µ¥¤¥È¤Î¥Ç¥¶¥¤¥ó¤¬¹¥¤­¤Ç»þ¡¹ÇÁ¤¤¤Æ¤¤¤¿ Lazyman smileys (embedded) - Glimpse of a Grrl ¤ò»²¹Í¤Ë¤µ¤»¤Æ¤â¤é¤¤¤Þ¤·¤¿¡£ ÀßÃÖË¡¤ò´Êñ¤ËÀâÌ... Read More

» Smilies from Daisyhead

I just added smilies to my comments, thanks toLisa-Grrl! It was very easy to do indeed and oh so much fun! And now I can smilies in my entries as well. So have fun!... Read More

PHP¤ò»È¤Ã¤Æ¡¢Ë¬Ìä¼Ô¤Ë¤è¤ë¥³¥á¥ó¥ÈÆâ¤Ë¥¹¥Þ¥¤¥ê¡¼²èÁü¤òËä¤á¹þ¤à¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ MT¤Î¥¢¡¼¥«¥¤¥Ö¥Õ¥¡¥¤¥ë¤Î³ÈÄ¥»Ò¤¬.php ¤Ç¤¢¤ë¤³¤È¤¬Á°Äó¤Ç¤¹¡£ ³ÈÄ¥»Ò¤Î³Îǧ¡¦Êѹ¹¤ò¤¹¤ë¤Ë¤Ï¡¢´ÉÍý¼Ô²èÌÌ¢ªBLOG¤ÎÀßÄꢪ¥¦¥§¥Ö¥í¥°¤ÎÀßÄ꤫¤é¡Ö¥¢¡¼¥«¥¤¥Ö¤ÎÀßÄê¡×¤Î2ÈÖÌܤˤ¢¤ë³ÈÄ¥»Ò¡... Read More

» Smilie Comments too! from Stitching up a Storm

Woo hoo again! :D I got the smilies working for the comments too... I might even go looking for some other smilies to add to them too. Let me know if there is any particular feeling you want to convey... Read More

» 200th entry from Simply Girly

this is my 200th post here at Simply Girly since Nov 10th 2003. I made my 100th post on Dec 17th 2003. I'm not so good with the counting, but I'm pretty sure that 100 posts in that time frame... Read More

» 200th entry from Simply Girly

this is my 200th post here at Simply Girly since Nov 10th 2003. I made my 100th post on Dec 17th 2003. I'm not so good with the counting, but I'm pretty sure that 100 posts in that time frame... Read More

» Boredom incites change from CosmicGoober

I did a lot of work on the Goob this morning - got the streaming cam up and running with lots of help from Lisa. I still have to get ahold of her today to figure out the flash version... Read More

» Boredom incites change from CosmicGoober

I did a lot of work on the Goob this morning - got the streaming cam up and running with lots of help from Lisa. I still have to get ahold of her today to figure out the flash version... Read More

» Boredom incites change from CosmicGoober

I did a lot of work on the Goob this morning - got the streaming cam up and running with lots of help from Lisa. I still have to get ahold of her today to figure out the flash version... Read More

» a listing from Incogblogo

This a running record of all the tricks I use to make my blog special... Read More

Lazyman smileys (embedded) - Glimpse of a Grrl... Read More

» Is It Friday Yet? from anything but ordinary

Cool. Mazeguy Smilies Speech Balloons CreatorFlash You can create your own speech balloons. There are several I plan to create. They'll have to go with my new set of smilies. :) [I've been meaning to implement some new smilies for... Read More

About this Entry

This page contains a single entry by Lisa published on March 8, 2003 9:09 PM.

Big decisions was the previous entry in this blog.

Damn allergens! is the next entry in this blog.

Find recent content on the main index.

Me!

"Insane people are always sure that they are fine. It is only the sane people who are willing to admit that they are crazy." — Nora Ephron

About me... :: memes :: My Amazon wishlist :: My LJ :: My Twitter :: My Flickr :: Photos of me

Blog reading list

Contacts
· AIM, Yahoo!, MSN, Google Talk, LJ Talk... just ask
· Email me

Good Causes

       
Love is love.
Support gay marriage.

platinum.gif
East siiiiiiiiiiiiiiiiiiiide, baby!
Click to help
sponsor mammograms
Listen to good music! Radio Paradise

Silly Stuff

blogchalk:
Lisa/Female/41-45. Lives in United States/Mass/Boston and speaks
English. Spends 80% of daytime online. Uses a Faster (1M+) connection.
The
WeatherPixie
The weather in Boston

Flickr

www.flickr.com
jasra's photos More of jasra's photos
Powered by Movable Type 4.21-en

Copyright

Copyright © 2001-8 Lisa K Holsberg. Unauthorized use is prohibited.