エントリーでテーブルタグを設定(ver3.17対応)
表タグを自動で挿入する方法です。
私の場合は写真を載せてその横に文字を挿入するのに使います。
1.イメージファイルをアップロード
/cgi/mt/imagesの配下に画像gifをアップロードします。
よろしければダウンロードして使ってください。
2.cgi/mt/tmpl/cms/edit_entry.tmplを修正
186行目からがエントリーの内容のボタンを決めています。
この中の
write('<a title="<MT_TRANS phrase="Bold" escape="singlequotes">" href="#" onclick="return formatStr(document.entry_form.text, \'strong\')"><img src="<TMPL_VAR NAME=STATIC_URI>images/html-bold.gif" alt="<MT_TRANS phrase="Bold" escape="singlequotes">" width="22" height="16" /></a>');
の上に
write('<a title="<MT_TRANS phrase="table" escape="singlequotes">" href="#" onclick="return insertTable(document.entry_form.text)"><img src="<TMPL_VAR NAME=STATIC_URI>images/table.gif" alt="<MT_TRANS phrase="Table" escape="singlequotes">" width="22" height="16" /></a>');
210行目からが追記のボタンを決めています。
この中の
write('<a title="<MT_TRANS phrase="Bold" escape="singlequotes">" href="#" onclick="return formatStr(document.entry_form.text_more, \'strong\')"><img src="<TMPL_VAR NAME=STATIC_URI>images/img.gif" alt="<MT_TRANS phrase="Bold" escape="singlequotes">" width="22" height="16" /></a>');
の下に
write('<a title="<MT_TRANS phrase="table" escape="singlequotes">" href="#" onclick="return insertTable(document.entry_form.text_more)"><img src="<TMPL_VAR NAME=STATIC_URI>images/table.gif" alt="<MT_TRANS phrase="Table" escape="singlequotes">" width="22" height="16" /></a>');
3.cgi/mt/mt.jsを修正
場所はfunction insertLink (e, isMail) {の上あたりに
function insertTable(e) {
if (!canFormat) return;
var str = getSelected(e);
if (!str) return;
setSelection(e, '<table><tr><td>' + str + '</td><td> </td></tr></table>');
return false;
}
以上です。