scriptygoddess

14 Mar, 2003

Extra field in comments

Posted by: Jennifer In: MT hacks

As requested by Chris, here's a hack that will give you an extra field for your comments, and have the contents of that field included in your email notification.

(note: what this will NOT do is show those contents back on your site. I can think of a way to do that with php and mySQL (with a slight detour on the comment form submission – similar to the way comment subscribe works) and I can write up a second tutorial on that one if there's interest. OR 10 points to the person that can figure out how to hack that directly into MT.)

(another note: if/when you do upgrades to MT – you will need to do this hack again (or one similar depending on how much changes in the version of MT you're working with). This tutorial assumes you're using MT 2.63 – although it also applies to 2.62)

Part One: Edit your comments form

Wherever you want the extra field to show (in this example, we're assuming people are entering the location of their RSS feed) add this:

<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 to be included in the email notification

This is the part that has to be re-done each time you upgrade (or replace your comments.pm file). Your Comments.pm file is (probably) located in this path:
mt/lib/MT/App/Comments.pm
Look for this line (probably around line 82):

$comment->author(remove_html(scalar $q->param('author')));

and add this line below it:

$comment->rssfeed($q->param('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" .

That's it. :)

2 Responses to "Extra field in comments"

1 | marc

November 21st, 2003 at 4:53 am

Avatar

Could you please post a tutorial on how MT archives and tags work.
This is the problem I am having.

From and outside link (a link to an entry from another site) the correct page is displayed, but also all the others, not just the individual archived page. I have both monthly, and individual archives selected in MT Config.

Thanks

2 | Scriptygoddess - Development

March 15th, 2003 at 2:42 pm

Avatar

Extra Field in comments
As posted on the main site here – I was able to figure out how to add an extra field

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements