再談 coComment 及 Ajax Comment

在 blog 內整合了 coComment 的好處就是可以正確取得有關資料,例如 blog 名稱、URL、文章標題、作者、留言內容等等,雖然如果在 blog 內沒有整合 coComment,coCo-crawler 會自行斷定以上資料,但因為 blog themes 多如繁星,而且沒有一個統一的標準,所以有機會 capture 錯誤的資料,使用過 coComment 的朋友一定見過文章標題錯誤甚至是 "(undefined)",原因就是 capture 錯誤,如果大家是使用一些不是預設支援 coComment 的 blog platform,但又可以整合 coComment 的話,我建議整合 coComment,待其他使用 coComment 的朋友有一個良好的留言環境,大家可參閱coComment 相容的 blog platform整合方法

如使用 WordPress,最方便的方法就是使用 coComment Enhancer Plugin,如果喜歡自己動手改 code,可以在 comments.php 內加入以下的 code。

<script type="text/javascript">
// this ensures coComment gets the correct values
coco =
{
     tool          : "WordPress",
     siteurl       : "<?php echo get_option('home'); ?>",
     sitetitle     : "<?php bloginfo('name'); ?>",
     pageurl       : "<?php the_permalink() ?>",
     pagetitle     : "<?php the_title(); ?>",
     formID        : "commentform",
     textareaID    : "comment",

     <?php if ( $user_ID ) : ?>
     author : "<?php echo $user_identity; ?>",
     <?php else : ?>
     authorID : "author",
     <?php endif; ?>
     buttonID      : "submit"
}
</script>
<script id="cocomment-fetchlet" src="http://www.cocomment.com/js/enabler.js" type="text/javascript">
// this activates coComment
</script>

其實以上所說的大部份之前都提過,現在越來越多使用 WordPress 的人選擇了 Ajax Comment, 不論是 theme 內置 Ajax Comment 功能,例如 K2 或是使用 Ajax Comment Plugin 都好,其實都是源自 ZeoAjax Comment,而 Ajax Comment Plugin 更加沒有完全跟足 Zeo 的做法,所以並不支援 Spam Karma 2,不過這是題外話,如果大家有興趣知道怎樣修改 Ajax Comment Plugin 相容於 Spam Karma 2 的話,我會另文詳談。

這次最重要是想說現在的 Ajax Comment 都是不支援 coComment 的,其實 Zeo 之前已經談過解決辦法,但不論是 K2 或是 Ajax Comment Plugin 都沒有把這修正收納在內,因為 Zeo 說會有一個小的後遺症就是當有錯誤出現時會不能顯示 error indicator,但是現在的 K2 好像沒有這個 image file,所以不肯定這個後遺症是否還存在。

修改方法其實很簡單,只需修改一個 file 內的一句 code。

1. K2 的修改方法

以 K2 0.9.1 作為例子,在 js/comments.js.php 中,function initComment() 內,即第 66 行由原來的

$('commentform').onsubmit = function() { AjaxComment(this); return false; };

改為

$('commentform').onsubmit = function() { AjaxComment(this); };

便可。

2. Ajax Comment Plugin 的修改方法

將 ajax-comments.php 內第 104 行

return false;

刪除便可。

16 Responses to “再談 coComment 及 Ajax Comment”

  1. 1729

    coComment的Firefox插件我已经停用了,虽然它功能很强,即使没有整合coComment服务的Blog,也可以记录自己的留言,但有时候它会严重影响浏览的速度,大概是因为每打开一个页面之前都会先连接coComment站点的缘故。

  2. 1727

    嗯, 與其自己在blog 內加scipt, 我寧願自己用cocomment 的firefox extension~
    另, scipt 可否加入if function exist 的語法?
    不然, cocomment 一down, 就可能有麻煩了?
    如早前gravator 死了, stannum就中了招! :p

  3. 1724

    小踢:起碼改改 Ajax Comment Plugin 待我在妳 blog 內的留言能儲在 coComment 吧?

  4. 1725

    天佑:講開 coComment,唔知係我既問題呢定係點呢…:P
    您呢到既文章,同一個留言,係 coComment 會出現兩次架,
    嗯…即係,明明得三個留言,上到 coComment 睇會變左有六個咁樣囉 ^^
    (我表達能力差,唔知您明唔明我講咩……:P)

  5. 1726

    @jaycy:這不是妳獨有的問題,因為除了整合了 coComment 的 blog 或是使用 Firefox extension 留言會被儲存到 coComment 外,還有另一個途徑,就是 cocoCrawler,cocoCrawler 是一個自動 process 用來 capture 所有留言,包括非 coComment 用戶留言,但它並不能辨認那些留言已被儲存,所以會出現 duplicated comments 的問題。

  6. 1732

    你咁少o黎留言, 邊會影響你o丫~
    咁, 為o左鼓勵你多d 探我,
    我索性off o左個ajax comment plugin 喇...
    嘿嘿...

  7. 1733

    [quote comment="12180"]你咁少o黎留言, 邊會影響你o丫~
    咁, 為o左鼓勵你多d 探我,
    我索性off o左個ajax comment plugin 喇...
    嘿嘿...[/quote]

    嘩,妳咁講即係投訴咁話喎。 :tongue1:

  8. 2655

    天佑你好,Ajax Comment 2.0似乎不支持wordpress 2.12?
    我在后台激活插件之后,留言不见有变化。
    comment是自己修改过的。

  9. 2635

    [quote comment="21097"]天佑你好,Ajax Comment 2.0似乎不支持wordpress 2.12?
    我在后台激活插件之后,留言不见有变化。
    comment是自己修改过的。[/quote]

    Ajax Comment Plugin 和 WordPress 2.1.2 是兼容的,但如果你同時使用 Spam Karma 2 的話,請參考我的文章《Spam Karma 2 與 Ajax Comment plugin》作出修改,否則 Ajax Comment 是不能運作的。

  10. 2711

    谢谢天佑,我没有使用Spam Karma2。
    但是我修改过comment.asp

  11. 2725

    [quote comment="21161"]谢谢天佑,我没有使用Spam Karma2。
    但是我修改过comment.asp[/quote]

    :confused: comment.asp?WordPress 沒有這個 file 吧?

  12. 2731

    谢谢天佑的回复
    不是asp,是comments.php
    以前用asp用的太多了。习惯了。不好意思。

    文件压缩放在这里 http://www.2gou.net/comments.rar
    有空的话,可以帮忙看看吗?
    谢谢了。

  13. 2592

    @愛狗:你的 comments.php 果然改動很大,亦是令到不能兼容 Ajax Comment plugin 的原因。因為 Ajax Comment plugin 的設計是針對一般 comments.php 的 template,即是留言是以 unordered list (<ol> <li>) 形式顯示,而那個 unordered list 的 ID 或 class 是要用 "commentlist" 這個名字的,所以你使用 <div> 的 comments.php 是不能兼容的。

  14. 2449

    收到,谢谢天佑抽空帮看。

  1. 1474 [2006/09/17 - 2006/10/16] 書籤摘錄 at Robbin 2.0
  2. 1854 Robbin 2.0» Blog Archive » 重新啟用img-code阻擋垃圾留言

Leave a Reply