Movable Type 3.2ja + MySQLの環境でコメントの入力項目(コメントタイトル)を追加した時のメモです。
MT本体をいじっているためにおいしくないのですが。。。
某所の非公開日記にメモっておいたのを、月別カレンダーの動作確認のためにしました。
■lib/MT/Comment.pm
install_propertiesのcolumn_defsの設定
title項目追加。
(DB用の設定?)
sub all_text
以下の行を追加。
$text .= "\n" . ($this->column('title') || '');
■lib/MT/Template/ContextHandlers.pm
init_default_handlers
以下の部分の追加
CommentTitle => \&_hdlr_comment_title,
sub _hdlr_comment_field
以下の行を追加
my $comment_title = "";
$comment_title = encode_html($ctx->_hdlr_comment_title()) || "";
sub _hdlr_comment_titleの追加
sub _hdlr_comment_title {
sanitize_on($_[1]);
my $tag = $_[0]->stash('tag');
my $c = $_[0]->stash($tag =~ /Preview/ ? 'comment_preview' : 'comment')
or return $_[0]->_no_comment_error('MT' . $tag);
my $t = defined $c->title ? $c->title : '';
$t ||= $_[1]{default} || '';
remove_html($t);
}
■lib/MT/App/Comment.pm
sub _make_comment
以下の行を追加
my $title = $q->param('title');
$comment->title(remove_html($title));
sub _send_comment_notification
my %paramの項目に以下を追加
comment_title => $comment->title,
■DB
comment_titleの列を追加
最近のコメント
└ かつお 11/14
└ ピストン 11/14
└ ピストン 11/14
└ テスト 05/25
└ mi 11/15
└ ピストン 11/15
└ ピストン 08/11