oldwain随便写 http://oldwain.itpub.net/
<a href="http://oldwain.itpub.net">oldwain随便写</a>
修改plog/LifeType模板支持coComment.
上一篇 / 下一篇 2006-02-20 00:00:00 / 个人分类:自产自销
主要参考资料: Making a Homebrew Blogging Tool coComment-compatible
基本原理:
通过修改Comment form中对象的名字,使得coComment将blog"识别"成其已经支持的blog系统之一。
注意之处:
- 由于comment form中的对象名字在提交后会被plog/lifetype程序引用,所以不能像参考文章中那样简单的改名。为此可以增加几个相应名称的隐藏对象,在原有对象内容改变后,通过script改变隐藏对象的内容。
- 参考文章中使用了TypePad作为"伪装"对象,由于LifeType与MovableType更为"像"一些,所以这里选用了MovableType作为伪装对象.
具体做法:
- 在header.template文件中加入<link rel="start" href={$url->bloglink()} title="Home" />
- 修改文章页面的title 为"blog名: 文章名"的格式
- 修改commentform.template中以下内容:
- 修改comment form 的id 为comments_form, name可以不变
- 增加隐藏域author, 当userName域发生变化时相应改变author域
- 增加隐藏域email, 当userEmail域发生变化时相应改变email域
- 增加隐藏域text, 当commentText域发生变化时相应改变text域
- 将提交按钮的名字改为post
修改后的comment.template内容类似下面的样子(仅用作示意,具体内容要根据自己所用模板内容进行修改):
<form id = "comments_form" name="NewComment" action="{$url->getBaseUrl()}/index.php" method="post" >
0t!|.WA(k0 {$locale->pr("comment_topic")}<br/>
fA[V*jQ;V+Q0 <input type="text" size="60" name="commentTopic" value="re: {$post->getTopic()}"/><br/>
,D d%E UV0 {$locale->pr("comment_text")} <br/>ITPUB个人空间%?rV5s Dm
<br />ITPUB个人空间1PCH(U9Q,g@{ W&Q
<input type="hidden" name="author" value="none"/>ITPUB个人空间Hp"^-t"a X g1a
<input type="hidden" name="email" value="none"/>
TaR+Kl/P(Oj/|:s.o0 <input type="hidden" name="text" value="none"/>
0t!|.WA(k0 {$locale->pr("comment_topic")}<br/>
fA[V*jQ;V+Q0 <input type="text" size="60" name="commentTopic" value="re: {$post->getTopic()}"/><br/>
,D d%E UV0 {$locale->pr("comment_text")} <br/>ITPUB个人空间%?rV5s Dm
<br />ITPUB个人空间1PCH(U9Q,g@{ W&Q
<input type="hidden" name="author" value="none"/>ITPUB个人空间Hp"^-t"a X g1a
<input type="hidden" name="email" value="none"/>
TaR+Kl/P(Oj/|:s.o0 <input type="hidden" name="text" value="none"/>
<textarea rows="10" cols="54" name="commentText" onchange="findObj('text').value = this.value" ></textarea><br/>
y&q k\g,Cg&w I0 {$locale->pr("comment_username")}<br/> <input type="text" name="userName" value="" onchange="findObj('author').value = this.value" /><br/>
3F w@0qD*e!i3X @0 {$locale->pr("comment_email")}<br/> <input type="text" name="userEmail" value="" onchange="findObj('email').value = this.value" /><br/>
9pt:k3qy+U'T0 {$locale->pr("comment_url")}<br/> <input type="text" size="60" name="userUrl" value=""/><br/>ITPUB个人空间m nj9zlc~N~d
<input type="submit" value="{$locale->pr("comment_send")}" name="post"/><br/><br/>ITPUB个人空间g`H+m"[ ~$E;J^?(Z
<input type="hidden" name="op" value="AddComment"/>ITPUB个人空间S2BAm'B/dK3Z
<input type="hidden" name="articleId" value="{$post->getId()}"/>ITPUB个人空间'p$K1E/iIa@inW
<input type="hidden" name="blogId" value="{$blog->getId()}"/>ITPUB个人空间Z)C0z$@1s&OgM
<input type="hidden" name="parentId" value="{$parentId}"/>ITPUB个人空间|6YGEx6[^e G
</form>
y&q k\g,Cg&w I0 {$locale->pr("comment_username")}<br/> <input type="text" name="userName" value="" onchange="findObj('author').value = this.value" /><br/>
3F w@0qD*e!i3X @0 {$locale->pr("comment_email")}<br/> <input type="text" name="userEmail" value="" onchange="findObj('email').value = this.value" /><br/>
9pt:k3qy+U'T0 {$locale->pr("comment_url")}<br/> <input type="text" size="60" name="userUrl" value=""/><br/>ITPUB个人空间m nj9zlc~N~d
<input type="submit" value="{$locale->pr("comment_send")}" name="post"/><br/><br/>ITPUB个人空间g`H+m"[ ~$E;J^?(Z
<input type="hidden" name="op" value="AddComment"/>ITPUB个人空间S2BAm'B/dK3Z
<input type="hidden" name="articleId" value="{$post->getId()}"/>ITPUB个人空间'p$K1E/iIa@inW
<input type="hidden" name="blogId" value="{$blog->getId()}"/>ITPUB个人空间Z)C0z$@1s&OgM
<input type="hidden" name="parentId" value="{$parentId}"/>ITPUB个人空间|6YGEx6[^e G
</form>
上面使用的findObj函数代码(来源于dreamweaver的示例代码):
function findObj(theObj, theDoc)ITPUB个人空间WR$D6qkL Sqk
{
^&Lj7KWyA0 var p, i, foundObj;ITPUB个人空间%q@,|4H%A(bP
u g/H4jM ho.j HT0 if(!theDoc) theDoc = document;