:::

14. XOOPS的評論功能

一、 如何讓同一個樣板檔可以支援不同畫面

  1. 利用<{if $樣板標籤=='值'}>畫面ㄧ<{else}> 畫面二<{/if}>即可達成。
  2. 程式部份則需加上$xoopsTpl->assign( "樣板標籤" , "值") ;

二、 加入評論功能(Comments)

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

三、 修改評論畫面

  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 note_title,note_content from ".$xoopsDB->prefix("tad_notes")." where note_sn='{$com_itemid}'";
        $result=$xoopsDB->query($sql);
        list($title,$com_replytext)=$xoopsDB->fetchRow($result);
    }
    $com_replytitle = "RE:{$title}";
    include XOOPS_ROOT_PATH.'/include/comment_new.php';
    ?>
  5. 如此一來,人家在評論的時候就可以清楚知道,正在回覆的是哪一篇,也不用自己填上標題了。

四、 修改評論畫面CSS

  1. 將「評論的CSS.txt」加入佈景檔的CSS檔中即可。

:::

搜尋

QR Code 區塊

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

書籍目錄

展開 | 闔起

線上使用者

21人線上 (2人在瀏覽線上書籍)

會員: 0

訪客: 21

更多…