
內容簡介
如果您有一個 phpBB 論壇,並想要把博客讀者引導到您的論壇中,那麼這個外掛或許可以幫助您,您可以在 WordPress 中的頁面、文章甚至是主題中包含最近的 phpbb 主題列表,以及在您的側邊欄中顯示!
關於資料庫配置
如果 WordPress 和 phpBB 共享相同的資料庫,那麼只要設定 $PHPBBDB 為 DB_NAME 即可,否則您需要將 WordPress 使用者設定為讀取 phpBB 的權限(如果您需要,您可以使用“不安全”的連線方式將 phpbb 資料庫憑證存儲在外掛中)。
如何讓 WordPress 讀取 phpBB 的唯讀權限?
如果您還不知道,您需要找到您的 WordPress MySQL 使用者 ID,它將在 wp-config.php 中:
define('DB_USER', 'wp_user'); // 您的 MySQL 使用者名稱
您也應該找到上述 phpBB 資料庫和表。
您需要在 MySQL 資料庫中輸入以下語法:
GRANT SELECT ON phpbb_database.phpbb_topics TO wp_user@localhost;
以及
GRANT SELECT ON phpbb_database.phpbb_forums TO wp_user@localhost;
以及
GRANT SELECT ON phpbb_database.phpbb_posts TO wp_user@localhost;
您可以作為 phpMyAdmin 資料庫使用者登入,選擇 SQL,並將正確的 GRANT 語法貼到文本框中以實現這一點。
如何使用不安全的資料庫連線方式
在 phpbb_recent_topics 外掛/設置頁面上,勾選“啟用不安全的資料庫連線”框,並提交,刷新頁面後,您會看到一些可以填寫的訊息,從您的 phpbb config.php 中填入:
$dbuser = phpbb MySQL 資料庫使用者名稱
$dbpasswd = phpbb MySQL 資料庫密碼
$dbhost = phpbb MySQL 伺服器:
點擊“更新”,即可完成連線!
回撥函數
為了允許使用者自定義顯示項目,已實現了一個回撥函數 phpbb_topics_callback。
在工單 1216 中,phil 建議在主題清單中顯示論壇名稱。以下代碼是新回撥函數的示例使用,應添加到您的主題 functions.php 中:
function phpbb_topics_callback($phpbbdb, $wpdb, $lnx_PRT_options, $topic) {
// 獲取發布文章所在的論壇 - Phil Ewels,2010 年 09 月 26 日
$sql_query = "SELECT * FROM $lnx_PRT_options[prt_phpbb_ft] WHERE forum_id=" . $topic->forum_id. " LIMIT 1";
# 執行查詢
if ($lnx_PRT_options['prt_phpbb_dbinsecureon'] == "1") {
$forum = $phpbbdb->get_row($sql_query);
} else {
$forum = $wpdb->get_row($sql_query);
}
echo "<br /><small>" . $forum->forum_name . " </small>";
}
以下變數可在回撥函數中使用:
* $wpdb
** 如果使用 Secure 連線,這是您到 PHPBB 資料庫的連線
** 如果使用 Insecure 連線,這是標準的 WordPress 資料庫
* $phpbbdb
** 如果使用 Secure 連線,這將是 NULL
** 如果使用 Insecure 連線,這是您到 PHPBB 資料庫的連線
* $lnx_PRT_options
** phpbb-recent-topics 設定的陣列
* $topic
** 當前話題,具有相關屬性。
外掛標籤
開發者團隊
原文外掛簡介
Do you have a phpBB forum, do you want to drag your blog readers into your forum ? Then this plugin might just help, you can include somewhere in wordpress a list of recent phpbb threads (topics) in a page, a post, and even in your theme – so your sidebar for example !
A bit about Database configuration.
If wordpress & phpBB share a DB already then set $PHPBBDB to DB_NAME and everything will be fine, else you.re going to need to GRANT the wordpress user read access to phpBB. (If you really need to, you can store the phpbb databse credential in the plugin using the “Insecure” connectivity method.)
How to GRANT wordpress read only access to phpBB ?
If you don.t know it already you need to find your wordpress mysql user id, it.ll be in wp-config.php
define('DB_USER', 'wp_user'); // Your MySQL username
and you should have already found your phpbb database & table for the above.
You need to type the following syntax into your mysql database
GRANT SELECT ON phpbb_database.phpbb_topics TO wp_user@localhost;
AND
GRANT SELECT ON phpbb_database.phpbb_forums TO wp_user@localhost;
AND
GRANT SELECT ON phpbb_database.phpbb_posts TO wp_user@localhost;
this can be achieved by logging into phpmyadmin as your phpbb user, selecting SQL and pasting the correct GRANT into the text box.
How to use the Insecure Database Connectivity Method
From the phpbb_recent_topics admin / settings page, tick the .Enable Insecure Database Connection. box, and submit, when the page re-freshes you.ll have some more boxes to populate, from your phpbb config.php fill in
$dbuser = phpbb MySQL Database UserName
$dbpasswd = phpbb MySQL Database Password
$dbhost = phpbb MySQL Server
Click update, and you should be connected!
The Callback function
To allow users to customize what is / can be displayed a callback function phpbb_topics_callback has been implemented.
In ticket 1216 (https://plugins.trac.wordpress.org/ticket/1216) phil suggested that the forum name should be displayed within the topic list; the following code is an example use of the new callback function and should be added to your themes functions.php
function phpbb_topics_callback($phpbbdb, $wpdb, $lnx_PRT_options, $topic) {
// GET FORUM WHICH POST IS IN - Phil Ewels, 26/09/2010
$sql_query = "SELECT * FROM $lnx_PRT_options[prt_phpbb_ft] WHERE forum_id=" . $topic->forum_id. " LIMIT 1";
# Run Query
if ($lnx_PRT_options['prt_phpbb_dbinsecureon'] == "1") {
$forum = $phpbbdb->get_row($sql_query);
} else {
$forum = $wpdb->get_row($sql_query);
}
echo "
" . $forum->forum_name . " ";
}
The following variables can be used within your callback function:
* $wpdb
** If using Secure Connectivity this is a connection to your PHPBB Database
** If using Insecure Connectivity this is the standard WordPress Database
* $phpbbdb
** If using Secure Connectivity this will be NULL
** If using Insecure Connectivity this is a connection to your PHPBB Database
* $lnx_PRT_options
** An array of the phpbb-recent-topics settings
* $topic
** The current topic, with associated attributes.
