« Ajax Rating v1.1 - Full Support for MT4 | Main | Add Comment Titles to MT4 Blogs »

Ajax Comments for MT4

Ajax Comments is a plugin for Movable Type 4 that enables your commenters to post comments using Ajax, without the page refreshing.

Live Demo

The best way to describe Ajax Comments is to show you. Try it out right now on the MT Test Blog. Click here to post a comment on the test entry.

Template Sets

To make Ajax Rating easy to setup, 6 templates are included. The following templates are new ones:

Ajax Comments Javascript (index template) - Contains links to the Javascript needed to posta comment.
YUI Javascript (template module) - Contains references to YUI Javascript libraries hosted externally.

...and 4 templates that are replacements for MT4 default templates: (Note: if you already customized these templates, you may have to do some manual template customization here. The installer will back up your existiing versions of these template.)

  • Comments (template module)
  • Comment Form (template module)
  • Comment Preview (system template)
  • Comment Response (system template)

The above templates can be easily installed by clicking the "install templates" button in the plugin settings (requires the Template Installer plugin).

Spam Protect

Ajax Comments can also be used to reduce your spam load significantly with "Spam Protect". Spam Protect is enabled by default, but you can disable it in the plugin settings. Spam Protect tricks automated spambots by tricking them into posting comments to the wrong URL. I have used this technique for a few years, and it makes a big difference is spam volume as server load. The one drawback to using Spam Protect is that commenters must have Javascript enabled to successfully post comments -- the tiny percentage of people who have Javascript disbaled will be sent to the "fake" Spam Protect URL. To minimize the CPU load from spambots, I recommend setting the Spam Protect URL to a non-existant page, so the bots will get a 404 "page not found" error.

Requirements

Installation

  • Download and extract the zip file. Upload the contents of the 'plugins' folder to the 'plugins' directory of your Movable Type installation.
  • Go the the plugin settings (Preferences > Plugins, then click Ajax Comments then Settings). Install the templates by clicking the button.
  • (Optional) Return to the plugin settings and adjust the Spam Protect settings and save.
  • Edit your "Header" template module. Go to Design > Templates then choose "Template Modules" from the right side of the page. Open the "Header" template. Look for a line that says:
    <MTIf name="feedback_template">

    After that line, add the following two lines:

    <$MTInclude module="YUI Javascript"$>
    <script type="text/javascript" src="<$MTLink template="ajax_comments_javascript"$>"></script>

  • Ensure that you have the "Use Comment Confirmation Page" setting checked under Preferences > Blog Settings > Comments. This is checked by default in new MT4 blogs. It must be checked for Ajax Comments to work.

  • Rebuild your Entry Archives.

Get Ajax Comments

Commercial License - $97.00

Personal License - Free

Ajax Comments is free for personal, non-commercial use.

Download Now

Download Now
Downloads: 996

As always, comments and suggestions are welcome.

Rate this entry:

  • Currently 3.8/5
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 3.8/5 (260 votes cast). Powered by the Ajax Rating plugin.

Comments (51)

Carlo Author Profile Page:

I can't post any comments on the test blog. I'm logged in but it asks me for name and email address. Otherwise.. the error handling and preview is amazing!

Carlo, thanks for reporting this. If you are logged in to MT Hacks, you will likely have to "sign out" first before the demo will work. This not a bug in the plugin, its just that the test blog is on a different MT installation than MT Hacks.

Carlo Author Profile Page:

You're right Mark. After I posted my comment here I logged out on the other blog and logged back in and was able to post. It all makes sense now.

The tag is not displaying dynamic content when I put it in my templates. I suspect this is because the when install the templates from plugin settings page, no YUI Javascript template module is created (it is not listed in my templates modules page). Any suggestions? Thanks!

Carlo Author Profile Page:

I installed it on my personal blog and it works fine, but i'm having trouble installing it on my public site since I'm using my own templates. Could you post a small manual on the templates and all? I'm trying to figure out everything but i'm a bit confused on what is absolutely necesary for the ajaxcomments to work.

Carlo, I do plan on writing a manual howto article on this. You should be able to glean the key points from the included templates, but here are some quick highlights:

The comment form needs a few changes. First, onclick argument to the open <form tag needs to be amended to include "postComment();". Second, a hidden field should be added named "ajax", set to a value of 1. Finally, each of the submit buttons need a new onclick argument, setting the "Action" variable (ie. onlick="Action='preview'" and onlick="Action='post'")

The "Comments" template needs <div id="ajax-comment"> to be added in two places. First right after the <MTCommentsFooter> tag. Secondly, right before the </MTComments> tag, add <MTElse><div id="ajax-comment"> (this deals with the case when an entry has no comments).

The "Comment Response" template needs a few edits. Looking at the included template should help here, but the key part to notice is that a large part of the template needs to be enclosed in the conditional <MTIfAjaxComments> tag. Inside that tag, is the output to be placed inline via AJAX. In the <MTElse> container goes the non-AJAX page content that is the page displayed when comment is not posted via AJAX.

The "Comment Preview" template works similar to the Comment Response template.

That's basically it, apart from the "Header" changes noted in the instructions above. I will try to expand this into a more detailed article in future.

(Another route to consider is to start with templates include with the plugin, then add back your own customizations. This may be quicker, depending on how much customization you have done.)

Carlo Author Profile Page:

Thanks Mark, these keys points should really help me out. I'll get to work on my templates and let you know how it goes. Great work!

Carlo Author Profile Page:

On a side comment.. how can I let users register system-wide? I want to use ajaxcomments on my whole site and each section is a different blog. Can you actually do that? (let users register on all blogs at once?)

Carlo, that issue is separate from the Ajax Comments plugin. This plugin uses the built-in registration/login tools that come with MT4, it doesn't modify them at all.

In MT4, I have heard that there is no easy way for users to register for all blogs on a system, but I haven't played with that yet. It might require another plugin to enable this.

Ajax comments will fit in nicely on my site. I have my main index set to show comments under each entry, hidden by default. How difficult would it be for me to have a small comment form pop up when the comments link is clicked, and use ajax for it to display right there on the main page without refreshing?

I would prefer to use a pop-up, although I suppose I could also hide the comment form under each entry and just have it expand along with the comments.

I have the plugin setup on one of my sites and when the entry page loads where the comments normally are I get a page not found and the error:

Smarty error: [in evaluated template line 16]: syntax error: mismatched tag {/if}. expected {/mtcomments} (opened line 6). (Smarty_Compiler.class.php, line 2286)

qwe:

gdfgdg

sevitzdotcom, not that this entry does not have Ajax Comments enabled. You need to click here to go to the live demo entry.

kodie Author Profile Page:

trst

Is there a way to change the "processing image" you can see on submitting the comments?

I can't find it within the plugin folders...

intervisual, that image comes with the MT4 application, and it is also used in the admin area. It can be found in your "static web path", such as

yoursite.com/mt-static/images/indicator.gif

If you want to show a different image, it may be best to edit the Ajax Comments Javascript template. Near the very bottom, you will see a line that references this image. Simply change the URL in the <img src="" to point to the image of your choice.

Thanks Mark! Regards Steffen

you guys always got great idea. thanks for all

justinmc Author Profile Page:

The part of the comments template seems to generate an error on dynamic entries. It has trouble with the part... not sure how to fix that.

cruv:

I am receiving the error message after I have installed this plugin:

Smarty error: [in evaluated template line 16]: syntax error: mismatched tag {/if}. expected {/mtcomments} (opened line 6). (Smarty_Compiler.class.php, line 2286)

What am I missing?

fred:

I installed the plugin and it works great expect i cannot get the comments to appear on the main home page. They do show up when you click on the main entry. What do I need to change on my templates to have the comments appear wit the entry on the home page? I followed the documentation exactly.

Thanks!

http://blog.fredsommer.com/fredsblog/

Hi,

Quite keen to implement this, but all my pages are dynamic expect the home page.

It seems from the comments above that this doesn't work so well with dynamic pages. Can I check if this works with dynamic pages and also there is a way to trigger rebuilds of index pages (like the home page) which may a Recent comments section.

Adrian

sevitzdotcom,

When posting comments using this plugin, it does trigger index rebuilds in the normal way.

The current version does not include PHP-dynamic versions of the template tags, but you could probably get it to work without them with a little template creativity. A future version may include dynamic versions of the tags, but you are the first to request that feature.

Mark,

All my entries are on dynamic pages and I don't want want to switch to static pages (for a variety of reasons)

I'll wait for the plugin that works with dynamic publishing. Pity as it's a great plug in.

Adrian

Very nice,

I got a javascript message on IE, 'Action' is not defined. I don´t know what can do this

blog2n Author Profile Page:

Hi!I installed the Ajax Comments on my personal chinese blog.and there is no error when I was installing it ,but I can't find in my header template,and I just copy it and the codes below that you ask to add to my header template.but I find the ajax comments doesn't work!Why?Can you help me?
my URL is http://www.youweilin.com

irina:

thank you for the script!
it is working just fine but there is the question of encoding.

My blog uses windows-1251, and with this plugin i get abracadabra.

how does it send comments to mt-comments?
where can i find the point it converts the encoding?

wordup Author Profile Page:

I'm getting this error:

Error
# Transaction id: 0
# HTTP status: 404
# Status code message: Not Found

Using version 4.1

Mike:

I set up Movable Type 4.1 but the comments were not working. I thought I needed an additional plug in so I installed Ajax Comments. I followed the directions loading the .pl file into an Ajax Comments directory under the plugin directory. I also set up the Template Installer.

The only thing I did not do was add the following lines in the header template because there was no line with in it.


">

Both plugins appear to be set up properly from the Movable Type administration plugin screens. My archives are set to Entry.

However, when I go to submit or preview a comment I get a "Page Cannot be Found" and it showed the url "www.crossfitpei.ca/mt-comment.cgi".

I would greatly appreciate your thoughts on this.

Thanks,

Mike

Mike:

It looks like the app parsed my tags that I added. I was referring to the lines to be added to the header template and the tag that was not in it to begin with was MTIf name="feedback_template".

tnx for your useful plug in, but i have a problem that i can't use it in ajax mode, when i submit the form it goes to mt-comment.cgi and shows what we have predict for ajax action.
how can i fix it?

i think it cause because the comment detail isn't in the plugin sets

hello, is this system obsolet? i´m trying it in a 4.2 installation without luck, the comments template has an error.

keeptry8:

Mark: Your instructions state: Open the "Header" template. Look for a line that says: After that line...

I am trying to set-up Ajax Comments on MT 4.2. I do not see a "Header" template. I do see 'Banner Header' and 'HTML Head' but neither one contains

Please assist.

the error was mine > regards

boywaja Author Profile Page:

same problem as seke. Has anyone gotten this to work on a template designed for 4.2? I had this working fine on a older style. When I upgraded styles/templates to 4.2 that is when the fun began.

I can't post any comments on the test blog. I'm logged in but it asks me for name and email address. Otherwise.. the error handling and preview is amazing!http://popeo.net/saishunkan/index.html

same problem as seke. Has anyone gotten this to work on a template designed for 4.2? I had this working fine on a older style. When I upgraded styles/templates to 4.2 that is when the fun began.
国内格安航空券

I am trying to set-up Ajax Comments on MT 4.2. I do not see a "Header" template. I do see 'Banner Header' and 'HTML Head' but neither one contains

Please assist.個別指導塾

I had this working fine on a older style. When I upgraded styles/templates to 4.2 that is when the fun began.多重債務 葬儀 千葉

I'll wait for the plugin that works with dynamic publishing. Pity as it's a great plug in.

Adrian

Posted by sevitzdotcom Author Profile Page | February 6, 2008 4:09 PM

国際協力
人権問題 

I set up Movable Type 4.1 but the comments were not working. I thought I needed an additional plug in so I installed Ajax Comments. I followed the directions loading the .pl file into an Ajax Comments directory under the plugin directory. I also set up the Template Installer.

The only thing I did not do was add the following lines in the header template because there was no line with in it.

asdf:

sdfgsd sdfg dsfg

Hans Author Profile Page:

Hi is this plugin working between 2 domains? MT is on another domain as my blog. Ajax commenting was a problem so I disabled it. Should this plugin work?

Me ubiqué en las otras antenas, me fijé en el material que usaban, me salió la idea y la fabriqué”, dijo Jean Carlos a LISTÍN DIARIO, que llegó hasta su casa para conocer su trabajo. En unas cuantas horas lograron la conexión. Sólo necesitaron un cable coaxial, un pedazo de cobre yuna olla vieja.

thanks mark

Very nice,

I got a javascript message on IE, 'Action' is not defined. I don´t know what can do this

you guys always got great idea. thanks for all

Post a comment