« 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

Membership required, please sign-in or register:

As always, comments and suggestions are welcome.

Rate this entry:

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

TrackBack

TrackBack URL for this entry:

Listed below are links to weblogs that reference Ajax Comments for MT4:

» Ajax Comments Test Entry from MT4 Test Blog
This is just a test entry to demonstrate the Ajax Comments plugin.To try it out, post a comment below.  You can sign-in if you want, or post anonymously -- it works both ways.Things to try:Hit the preview button first to see an in-line preview of ... [Read More]

» AJAX Based Comments for MT4 from Movable Type 4
Mark Carey has released yet another plugin for MT that brings AJAX powered comments to MT4AJAX is one of those web 2.0 buzzwords that can be abused and overused, however if used correctly, such as in this instance, it can... [Read More]

» AjaxComment Revolutions(AjaxComments Plugins) from WolaWola
MT4用の AjaxComment 、ほぼMT3.3と同様の手順で導入可能だが、MT-Hackからプラグインとしても登場している。簡単に導入するなら、こちらの方が良いので、初心者向けかも。 [Read More]

» Ajax Comments For MT4 from Shadowscope
I'm testing out Ajax Comments for Movabletype here. It probably won't speed things up unfortunately but it posts a comment without refreshing the entire page, which may speed it up a tiny bit. I am still planning to move Shadowscope... [Read More]

» Ajax Comments from TheAppDotNet
One of the things I am trying to add to the site are Ajax Comments. This is a terrific plugin by Mark Carey and I used it briefly on my personal site but really had no need for it at... [Read More]

» Moving Right Along... from TheAppDotNet
I ended up trashing the templates I had going and moved to a dedicated MT install because of some issues I was having with plugins. The header is up now (obviously). What do you think? I will have my links and sidebars back in shortly, along with some ... [Read More]

Comments (31)

Carlo [TypeKey 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 [TypeKey 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 [TypeKey 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 [TypeKey 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 [TypeKey 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 [TypeKey Profile Page]:

trst

intervisual [TypeKey Profile Page]:

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.

intervisual [TypeKey Profile Page]:

Thanks Mark! Regards Steffen

you guys always got great idea. thanks for all

justinmc [TypeKey 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 [TypeKey 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 [TypeKey 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".

Post a comment

Gift idea: Buy Seinfeld DVD box set, complete 9 seasons!