
語言 🇹🇼 繁體中文
簡要說明
Drupal 安裝
投票
為 Drupal 網站新增即時評論
快速入門 
這是 Drupal 說明的「太長不看」版本。
- 使用
composer require drupal/fcom安裝模組,或將其放入modules/custom/fastcomments/。 - 使用
drush en fastcomments啟用,或在管理介面/admin/modules中啟用。 - 前往
Administration > Configuration > Content > FastComments(/admin/config/content/fastcomments)。 - 在 Settings > API/SSO(EU)中輸入您的 Tenant ID 與 API Secret。
- 透過
Structure > Content types > [type] > Manage fields將FastComments欄位新增到任一內容類型。
該模組已發佈於 drupal.org/project/fcom。
安裝 
FastComments Drupal 模組以快速、即時的留言系統取代 Drupal 內建的留言功能。該模組已發佈於 drupal.org,並支援 Drupal 10 與 11。
有兩種安裝方式。
使用 Composer 安裝
composer require drupal/fcom
drush en fastcomments
手動安裝
從 drupal.org/project/fcom 下載模組,並將其放置於您網站的 modules/custom/fastcomments/ 目錄中。然後使用 drush en fastcomments 啟用它,或從管理介面的 Extend(/admin/modules)中啟用。
注意! 此模組僅依賴 Drupal 核心(user 與 field)。不需要其他 Drupal 模組或函式庫。
模組啟用後,請前往 Configuration 區段設定您的 Tenant ID 與 API Secret。
設定 
所有設定位於 Administration > Configuration > Content > FastComments (/admin/config/content/fastcomments) 下。
必要設定
- Tenant ID - 您的 FastComments 租戶 ID。可在 Settings > API/SSO(EU)中找到。
- API Secret - 用於安全 SSO、Webhook 驗證與頁面同步的必備資訊。可在 Settings > API/SSO(EU)中找到。
儲存 API Secret
模組會從以下來源中依序讀取第一個有值的 API Secret:
- Key module - 安裝 Key,建立一個 Authentication 金鑰,並在設定表單的 API Secret key 中選取。此金鑰可由環境變數或網站根目錄外的檔案提供。
- settings.php - 在
settings.php或settings.local.php中加入$config['fastcomments.settings']['api_secret'] = 'your-secret';。此密鑰不會寫入匯出的設定檔。 - 設定表單 - 在 API Secret 欄位中輸入。此值會儲存在
fastcomments.settings中,因而會出現在設定匯出。Drupal 狀態報告會在此為使用中的來源時發出警告。
表單會顯示目前使用的來源。將欄位留空可保留已儲存的密鑰。勾選 Remove the API Secret stored in configuration 可在將密鑰移至 Key 模組或 settings.php 後刪除它。
評論樣式
選擇符合您網站上使用者交流方式的元件。
- Live Comments - 即時的分支式評論。
- Streaming Chat - 直播聊天介面,適合活動與直播。
- Collab Chat - 於主要內容區域的文字選取註解。訪客可標記文字並在上下文中發起討論。
- Collab Chat + Comments - 同時在同一頁面提供協作聊天與標準評論。
SSO 模式
- None - 不使用 SSO。使用者以訪客身分評論或建立 FastComments 帳號。
- Simple - 將 Drupal 使用者資訊(名稱、電子郵件、頭像)傳遞給 FastComments,無需伺服器端驗證。
- Secure - 使用 HMAC‑SHA256 來驗證 Drupal 使用者與 FastComments 的關聯。建議在已設定 API Secret 時使用。
請參閱 Single Sign-On (SSO) 章節以取得詳細資訊。
其他設定
- CDN URL - 預設為
https://cdn.fastcomments.com。 - Site URL - 預設為
https://fastcomments.com。 - Email notifications - 當有新評論發佈於內容上時,會向內容作者發送電子郵件通知。
關於 EU 資料居留,請參閱 EU Data Residency 章節。
小工具區塊 
此模組提供數個區塊,可以從 Structure > Block layout (/admin/structure/block) 放置。
- FastComments Widget - 主要的留言元件。會自動偵測當前實體。它會跳過已附加 FastComments 欄位的實體,因此您不會在相同頁面看到重複的元件。
- FastComments Live Chat - 即時串流聊天。可以與相同頁面的評論欄位並排放置。
- FastComments Collab Chat - 文字選取的註解與討論。
- FastComments Image Chat - 基於座標的圖片註解。訪客點擊圖片即可留下與特定位置相關聯的評論。
- FastComments Recent Comments - 顯示整個網站的最新評論。數量可在區塊上設定。
- FastComments Top Pages - 顯示網站上評論數最多的頁面。
以內容為中心的區塊(Live Chat、Collab Chat、Image Chat)會自動偵測當前實體,並在非實體頁面時退回使用基於路徑的識別符。這表示它們可在分類法頁面、Views 與自訂路由上運作,無需任何額外設定。
內容類型欄位 
對大多數網站而言,新增留言最簡單的方式是將 FastComments 欄位附加到您的內容類型。前往 Structure > Content types > [type] > Manage fields 並新增該欄位。
每個具有此欄位的實體都會獲得:
- 一個狀態開關,讓編輯者可以針對每個實體開啟或關閉留言功能。
- 一個可選的自訂識別碼,讓您可以使用不綁定於 Drupal 實體路徑的穩定 ID。
主要的 FastComments Widget 區塊會偵測此欄位,並跳過已附加該欄位的實體。如此一來,您可以將每個實體的留言與區塊混合使用,而不會在同一個頁面上看到重複的 widget。
單一登入 (SSO) 
FastComments 透過 SSO(單一登入)與 Drupal 的使用者系統整合。使用者登入您的 Drupal 網站後,模組會自動將他們的身分傳送到 FastComments。無需建立額外帳號,也不需要執行初始同步。
The module supports three SSO modes, set under Administration > Configuration > Content > FastComments.
無
No SSO。使用者可以訪客身份留言或建立 FastComments 帳號。若您的網站公開且不需要將留言綁定到 Drupal 使用者,請使用此模式。
簡易
在沒有伺服器端驗證的情況下,將 Drupal 使用者的名稱、電子郵件與大頭照傳給 FastComments。無需 API Secret。適用於內部或低風險網站。
安全(建議)
使用 HMAC-SHA256 來向 FastComments 驗證每個使用者的身分。若您已設定 API Secret,此模式即為您所需,且它是唯一能防止訪客冒充其他使用者的模式。
User identity is passed to FastComments each time a user views a comment thread. There is no initial or continuous sync that needs to run.
(Optional) 將您的管理員加入 Users & Administrators,並將版主加入 Comment Moderators,以改善他們的使用體驗並啟用版主的統計追蹤。
如要深入了解 SSO 的運作方式,請參閱自訂文件的 SSO 章節。
權限 
此模組新增三個 Drupal 權限,可在 People > Permissions 下為每個角色分配。
- Administer FastComments - 可存取位於
/admin/config/content/fastcomments的 FastComments 設定表單。 - View FastComments - 需要此權限才能看到留言小工具。沒有此權限時小工具不會渲染。
- Toggle FastComments - 允許使用者使用欄位小工具針對每個實體啟用或停用評論。
預設只有擁有 administer site configuration 權限的使用者可以變更 FastComments 設定。若您希望訪客能看到小工具,請將 View FastComments 權限授予匿名及已驗證的使用者。
多語系 
此模組會自動將目前 Drupal 站點的語言傳遞給每一個 FastComments 小工具。如果您的 Drupal 站點設定為多種語言,留言介面將在對應語言中呈現,無需任何額外設定。
這適用於所有小工具類型:Live Comments, Streaming Chat, Collab Chat, Image Chat, Recent Comments, and Top Pages.
歐盟資料居留 
如果您的 FastComments 帳戶託管在歐盟 (EU),請在 Administration > Configuration > Content > FastComments 更新兩個設定:
- CDN URL -
https://cdn-eu.fastcomments.com - Site URL -
https://eu.fastcomments.com
您還需要從位於 eu.fastcomments.com/auth/my-account/api 的歐盟儀表板中擷取您的 Tenant ID 和 API Secret,而不是從預設的美國儀表板。模組的其他部分則相同。
自訂 
FastComments 的設計可進行自訂,以配合您的網站。
如果您想加入自訂樣式或調整設定,查看我們的自訂與設定文件 以了解如何操作。
需求 
- Drupal 10 或 11
- PHP 8.1 或更新版本
- 一個 FastComments 帳戶
此模組不需要任何其他 Drupal 模組或第三方函式庫。它僅依賴 Drupal 核心 (user, field)。
一個 <noscript> 回退會為未啟用 JavaScript 的訪客提供伺服器端渲染的留言,因此在停用腳本的瀏覽器中,Live Comments 和 Streaming Chat 仍然可以運作。