A while back Chris had asked about getting an extra field in the comments form. At the time all I could do was figure out a way to get the field emailed to you. But thanks to a few lessons I learned in the last script/MT-hack I wrote – I've figured out how to do it all. So this is part MT-hack and part plugin.
Here's a summary of what this does:
You add a field in your comments form to collect RSS feed's from your commenters and then you can display it back in your comments on your site – just like you do with their blog-URL.
What's involved:
You'll be editing any template you use that displays comments or the comment form, and install a plugin (which is as simple as uploading a file to your site) As well, You'll need to edit two MT files and the mt-database. If you're not comfortable doing this – I suggest you set up a test MT install and play with this first.
Here is the download for the plugin. The tags associated with the plugin will not work on their own – you'll need to follow all of the instructions (below).
Some credit notes: A MASSIVELY HUGE THANK YOU to "Milbertus" (A.) of milbertus.com for writing the plugin for the MTCommentFeed tag (MTCommentPreviewFeed tags still in development at this time) (I wrote the plugin for the MTCommentIfRSS tag. w00t!)
Part One: Edit your comments form
In your comments form, add this:
Your RSS Feed: <input type="text" name="rssfeed" />
If you have the "remember me" cookies working on this page, and you'd like this field to also be remembered, look for your "remember me" and "forget me" functions (towards the top of your page), and just add the line that I have in red/bold text:
function rememberMe (f) {
var now = new Date();
fixDate(now);
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
setCookie('mtcmtauth', f.author.value, now, ", HOST, ");
setCookie('mtcmtmail', f.email.value, now, ", HOST, ");
setCookie('mtcmthome', f.url.value, now, ", HOST, ");
setCookie('mtcmtrssfeed', f.rssfeed.value, now, ", HOST, ");
}
function forgetMe (f) {
deleteCookie('mtcmtmail', ", HOST);
deleteCookie('mtcmthome', ", HOST);
deleteCookie('mtcmtauth', ", HOST);
deleteCookie('mtcmtrssfeed', ", HOST);
f.email.value = ";
f.author.value = ";
f.url.value = ";
f.rssfeed.value =";
}
Now look towards the bottom for the page for the code below and add what I have in red/bold
<script type="text/javascript" language="javascript">
<!–
document.comments.email.value = getCookie("mtcmtmail");
document.comments.author.value = getCookie("mtcmtauth");
document.comments.url.value = getCookie("mtcmthome");
document.comments.rssfeed.value = getCookie("mtcmtrssfeed");
//–>
</script>
Part Two: Getting the field into the MT database.
You will need to run this SQL query. I suggest going into phpMyAdmin (if your
host provider has this). Click on the SQL tab, and paste the line below in the
field, and then click go.
ALTER TABLE mt_comment ADD comment_author_rss VARCHAR( 255 ) ;
Part Three: Edit Comments.pm
This is the part that has to be re-done each time you upgrade (or replace your comments.pm file). Your Comments.pm file should be located in this path: yourMTfolder/lib/MT/App/Comments.pm
Look for this line (probably around line 82):
$comment->author(remove_html(scalar $q->param('author')));
and add these lines below it:
my $rssfeed = $q->param('rssfeed') || ";
if ($rssfeed) {
require MT::Util;
if (my $fixed2 = MT::Util::is_valid_url($rssfeed)) {
$rssfeed = $fixed2;
} else {
return $app->handle_error($app->translate(
"Invalid URL '[_1]'", $rssfeed));
}
}
$comment->author_rss(remove_html($rssfeed));
Look for this line (probably around line 150):
$app->translate('URL:') . ' ' . $comment->url . "\n\n" .
and add this line below it:
$app->translate('RSS Feed:') . ' ' . $comment->rssfeed. "\n\n" .
Part Four: Edit Comment.pm
This will also need to be re-done each time you upgrade (or replace your Comment.pm file). Your Comment.pm file should be located in this path: YourMTFolder/lib/MT/Comment.pm
Look for this line
'id', 'blog_id', 'entry_id', 'author', 'email', 'url', 'text', 'ip'
CHANGE it to (you're just adding the 'author_rss', in there:
'id', 'blog_id', 'entry_id', 'author', 'email', 'url', 'author_rss',
'text', 'ip'
Part Five: Using the Plugin:
Here's an example of how the tags will work. This site uses this plugin and mt-hack, so you can see how it is displayed.
<MTCommentIfRSS>
<a href="<$MTCommentFeed$>">My RSS Feed</a>
</MTCommentIfRSS>
(MTCommentPreviewFeed example coming…)
Part Six/Addendum: Comment Subscribe modification
If you use "subscribe to comments" script, you'll also need to edit the processing.tmpl file that came with the script. Add this to the form on that page: