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系统之一。

注意之处:

  1. 由于comment form中的对象名字在提交后会被plog/lifetype程序引用,所以不能像参考文章中那样简单的改名。为此可以增加几个相应名称的隐藏对象,在原有对象内容改变后,通过script改变隐藏对象的内容。
  2. 参考文章中使用了TypePad作为"伪装"对象,由于LifeType与MovableType更为"像"一些,所以这里选用了MovableType作为伪装对象.
ITPUB个人空间)z*gT0AoMl$Y

具体做法:

  • 在header.template文件中加入<link rel="start" href={$url->bloglink()} title="Home" />
  • 修改文章页面的title 为"blog名: 文章名"的格式
  • 修改commentform.template中以下内容:
    1. 修改comment form 的id 为comments_form, name可以不变
    2. 增加隐藏域author, 当userName域发生变化时相应改变author域
    3. 增加隐藏域email, 当userEmail域发生变化时相应改变email域
    4. 增加隐藏域text, 当commentText域发生变化时相应改变text域
    5. 将提交按钮的名字改为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*j Q;V+Q0 <input type="text" size="60" name="commentTopic" value="re: {$post->getTopic()}"/><br/>
,D d%E UV0 {$locale->pr("comment_text")} <br/>ITPUB个人空间%?rV5sDm
<br />ITPUB个人空间1PCH(U9Q,g@{W&Q
<input type="hidden" name="author" value="none"/>ITPUB个人空间Hp"^-t"aX 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个人空间mnj9zlc~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/i Ia@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

ug/H4jMho.j H T0 if(!theDoc) theDoc = document;
lI c`"o)g]F0 if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)ITPUB个人空间:~1`p$R/E&Px9g
{
6B!VrJvP t/c0 theDoc = parent.frames[theObj.substring(p+1)].document;
3{+W'Me%{&}${0 theObj = theObj.substring(0,p);
loY%b!p-J0 }
m)[o5K,sf0 if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];ITPUB个人空间z8zc)CI3n-K5lU
for (i=0; !foundObj && i < theDoc.forms.length; i++) ITPUB个人空间H;~_4o H
foundObj = theDoc.forms[i][theObj];
wLOfSJD0 for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) ITPUB个人空间iw_ fT[iD;M9XX
foundObj = findObj(theObj,theDoc.layers[i].document);ITPUB个人空间8a9d5}]GH2c f
if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);ITPUB个人空间{h F CdRs?

%C O9{x6{:L?sf`0 return foundObj;ITPUB个人空间5|vw-l?I1x/\
}
Technorati Tags: , ,

TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-11-23  
      1
2345678
9101112131415
16171819202122
23242526272829
30      

数据统计

  • 访问量: 2741
  • 日志数: 1042
  • 建立时间: 2007-11-28
  • 更新时间: 2008-02-22

RSS订阅

Open Toolbar