:::

14. XOOPS的評論功能

一、 加入評論功能(Comments)

  1. 若是想要在模組中套用評論功能,那麼必須設定以下項目:
  2. //---評論---//
    $modversion['hasComments'] = 1;
    $modversion['comments']['pageName'] = 'view.php';
    $modversion['comments']['itemName'] = 'honor_sn';
    • (1)  $modversion['hasComments'] = 1; //是否啟用評論功能?
    • (2)  $modversion['comments']['itemName'] = 'honor_sn'; //評論項目的唯一辨識欄位的名稱(給程式用的)
    • (3)  $modversion['comments']['pageName'] = 'view.php'; //要加入評論的頁面
  3. 接著把「評論檔」中的五個檔案複製到「模組根目錄」即tad_honor下。
  4. 在view.php的下方include....foot.php前加入一行:
  5. include_once XOOPS_ROOT_PATH.'/include/comment_view.php';
    include_once XOOPS_ROOT_PATH.'/footer.php';
    ?>
  6. 開啟「評論樣板檔語法.txt」,複製語法到樣版檔tad_honor_view_tpl.html中
  7. <div style="text-align: center; padding: 3px; margin: 3px;">
      <{$commentsnav}>
      <{$lang_notice}>
    </div>
    
    <div style="margin: 3px; padding: 3px;">
    <!-- start comments loop -->
    <{if $comment_mode == "flat"}>
      <{include file="db:system_comments_flat.html"}>
    <{elseif $comment_mode == "thread"}>
      <{include file="db:system_comments_thread.html"}>
    <{elseif $comment_mode == "nest"}>
      <{include file="db:system_comments_nest.html"}>
    <{/if}>
    <!-- end comments loop -->
    </div>
  8. 到後台更新您的模組(為了重讀樣版及設定檔),就大功告成囉!

三、 修改評論畫面

  1. 替評論加上「$com_replytitle」回覆標題,及「$com_replytext」被回覆的內容。
  2. 這兩個變數的值,我們利用該文章編號「$com_itemid」直接撈出該文章的標題和內容即可。
  3. 修改comment_new.php
  4. <?php
    include '../../mainfile.php';
    $com_itemid = isset($_GET['com_itemid']) ? intval($_GET['com_itemid']) : 0;
    if ($com_itemid > 0) {
      $sql="select `honor_students` , `honor_descript` from ".$xoopsDB->prefix("tad_honor")." where honor_sn='{$com_itemid}'";
        $result=$xoopsDB->query($sql);
        list($honor_students , $honor_descript) = $xoopsDB->fetchRow($result);
    }
    $com_replytitle = "RE:{$honor_students}榮獲{$honor_descript}";
    $com_replytext = "";
    include XOOPS_ROOT_PATH.'/include/comment_new.php';
    ?>
  5. 如此一來,人家在評論的時候就可以清楚知道,正在回覆的是哪一篇,也不用自己填上標題了。

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Fwww.tad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D25%26tbdsn%3D704

書籍目錄

展開 | 闔起

線上使用者

30人線上 (9人在瀏覽線上書籍)

會員: 0

訪客: 30

更多…