When you read the recent comments in the right-hand sidebar in this blog, you may find sometimes people write me comments with smiley emoticons. For those who can't read Chinese, the recent comments that I'm talking about is the piece of white paper in the rightmost column in this blog, below the yellow post-it and above the Google ads bar.
Actually I'm not the first one who works on this kind of hack. When I find this funny idea I tried to google for some readymade code and implement in my blog. However, some of the codes that I found do not support IE6, and some codes loop heavily and result in very unstable webpage loading. After a few unsuccessful trails, I decided to use my own way to code this hack. I tested the current hack in Firefox 3, IE6, IE8 and Google Chrome, and so far did not find any problem. In this article I'll show you how to make your blogger comments smile.

As different blogger template has different layout, and you may place you comment form as full page, pop-up or embedded below post, the codes in your template can look very different from mine. In this post I'll explain the hack base on the standard 'Rounders 4' template that you can find under Layout => Pick New Template in the blogger's control panel, and I'll setup the comment form as 'embedded below post'. If you can't find the code segments in my explanation, you may try to test the implementation with a test blog base on the standard Rounders 4 template. Once you workout the hack successfully you may compare the codes in your test template against your live template and try to figure out where to place the codes.

So here is the step-by-step explanation.

Step 1: Login to blogger, and from the control panel, go to Layout => Edit HTML, and put a tick in the Expand Widget Templates checkbox. Search in the Edit Template Box for the tag <head>. Under the <head> tag add the following codes (only the red lines):

Step 4: Start from the position that you just place the tag <div id='emocomment'> in Step 3, scroll down and find the first </dl> tag, and below that tag insert the following codes (only the red lines):

Step 3 and Step 4 is a bit tricky. The tag that you are looking for in Step 3 may have different variation, like:
<dl class='comments-block' id='comments-block'> or,
<dl expr:class='data:post.avatarIndentClass' id='comments-block'>

What you needs to find is a <dl> tag with id='comments-block', and that <dl> tag represent the start of the comment list in your blog. Before that open <dl> tag you add the code segment in Step 3, and after the immediate closing </dl> tag you add the code segment in Step 4.

However, the comment list in some template does not start from any tag with id='comments-block', and in such situation you won't find anything in your template with the code phrase id='comments-block'>. For example, the comment list in one template that I studied before start from a <div class='commentlist'> tag. Since the comment list already display between a <div> tag, you may simply add an id to that <div> tag, by changing the tag as <div class='commentlist' id='emocomment'>. As that <div> tag already has its own closing </div> tag, you don't need to perform Step 4 in such circumstance.

One more example, the comment list of the Desktop Chaos template that you see in this blog start from a tag likes that:
<ol class='commentlist'>

In such case, once you identify that <ol> tag, insert the code segment in Step 3 before it, find the immediate closing </ol> tag, and insert the code segment in Step 4 after it. Sometimes it needs some trail and error for you to figure out exactly which block of code that you should enclose with the <div id='emocomment'></div> tag.

Okay, after you find your way to complete Step 3 and 4, you can test by writing a comment and insert smiley codes like :) or :D. The codes should turn to emoticons in your comment posts. The next step you'll tell your visitors what smiley codes are available to them. You may scroll to the bottom of this post, just above the comment form, to see how this list of emoticons look like.

Step 5: Go back to the Edit HTML panel, tick the Expand Widget Templates checkbox, find the tag <b:if cond='data:post.allowNewComments'>, and insert the following codes (again, only the red lines):

In some template the tag <b:if cond='data:post.allowNewComments'> may not be exist. In such case if you find the tag <b:if cond='data:post.embedCommentForm'>, you may put the code segment below that tag instead. Other template may have variation in its coding structure and you need to figure out the best place you want to put this emoticon list in your own template.

You may change the background color of this emoticon list by changing the hexadecimal numbers behind the background parameter in the first <div> tag in the code segment:
<div style='text-align: center; border: 1px dotted #cccccc; border-width:1px 0; padding: 5px; background: #557777;'>

#557777 means I applied 55 red, 77 green and 77 blue to create the background color. Each hexadecimal number can start from 00 to ff. You can alter the 3 numbers to match the background color with your blog design.

As you create the recent comments through the RSS Feed gadget, remember the title that you specified.

Step 6: After the recent comments show up in your sidebar, go back to the Edit HTML panel, tick the Expand Widget Templates checkbox, and search the title text that you specified for your recent comments. In my example, I search with the text 'Comment List Blog in Test' and find the following block of code. Add the red lines below the <h2><data:title/></h2>, and above the <b:include name='quickedit'/> tag, as follow:

Check your blog if the smiley codes in your recent comments turn to emoticons, and if yes, congratulation! Now you got a blog that people can comment you with a smile.

Regarding the post content in your blog, I don't recommend to implement similar hack. Changing the innerHTML of the post content with this kind of hack may create many problems, especially if you have other javascript function enhancement in your blog. If I need a smiley icon in my post, I'll simply copy and paste an image tag like this <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/4.gif" style="border-width: 0px; padding: 0pt; vertical-align: middle;" /> in my post.

One last point, recently I found many people leave me comments with just emoticons. I really appreciate your responses; however, too much such kind of comments will empty the Recent Comment Box and leave that piece of perforated paper on the right hand side of this blog nothing but five smiley icons. So in case you wish to leave a comment in this blog, please at least write a few words in your language. Comments with emoticon only will be rejected in this blog. Personally I don't like my blog looks like a testing platform , so please also don't add words like "testing" or "測試" in your comments. Thanks for the cooperation.