我正在尝试将PHPBB3论坛的论坛Feed整合到外部Frontpage中。
为此,我使用了phpbbwiki中的一个例子: here is the code
我的问题是,只有在论坛上已经对用户进行了身份验证,这才有效,但我希望用户能够看到对访客用户开放的主题,而不是PHPBB默认(空白)页面。
在这种情况下,我使用ajax返回JSON中的主题,但这对我的问题来说并不重要。
最好知道这是否可以在PHPBB能够提供的范围内实现,以及从哪里开始查看这是否是一个更复杂的问题。
如果这对你们中的一些人来说很简单,我将不胜感激。
谢谢!
更新
未创建用于检索帖子的SQL语句,因为用户似乎没有读取权限。失败的条件是(funnction:create_where_clauses):
// If the type is forum, do the check to make sure the user has read permissions
else if( $type == 'forum_id' && $auth->acl_get('f_read', $id_check) )
其中id_check是当前的forum_id。
以下是用户数据对象的一部分:
["user_id"] => string(1) "1"
["user_type"]=> string(1) "2"
["group_id"] => string(1) "1"
此用户位于GUESTS组中,默认情况下其类型为IGNORE。 我已经尝试将user_type设置为0 = NORMAL - 无效。
作为PHPBB3论坛的普通访问者,我可以阅读所有公开论坛,我想知道 为什么这个通用访客用户无法访问论坛。
更新和解决方案
我要感谢你的回答让我再次走上正轨。 我会无休止地寻找PHPBB用户管理深度的解决方案 当我犯的原始错误只是一个愚蠢的复制/粘贴问题......
$forum_id = array(2, 5);
$forum_id_where = create_where_clauses($forum_id, 'forum');
$topic_id = array(20, 50);
$topic_id_where = create_where_clauses($topic_id, 'topic');
这两行来自教程,在尝试检索时仍然存在 来自“所有”论坛和主题的数据。顺便提一下,那些论坛ID对注册用户开放 并且对未经过身份验证的用户关闭。提升上述内容时限制脚本 再次按原样执行。
再一次 - 特别感谢安迪。
答案 0 :(得分:1)
空白页面是因为您的external_body.html
目录中没有style/prosilver/templates
文件。
非常基本的external_body.html
看起来像这样。显然,你必须将它整合到你的主页主题中。
<!-- BEGIN announcements -->
Title: {announcements.TOPIC_TITLE}<br />
Post author: {announcements.POST_AUTHOR}<br />
Post date: {announcements.POST_DATE}<br />
Last post text: {announcements.POST_TEXT}<br />
Post link: {announcements.POST_LINK}
<!-- END announcements -->
然后,使用phpBB.com MOD团队的battye提供的文件,并将其放在论坛的根目录中,您可以显示最新的帖子。
external_page.php
<?php
/*
* Description: example file for displaying latest posts and topics
* by battye (for phpBB.com MOD Team)
* September 29, 2009
* Modified for StackOverflow Question: http://stackoverflow.com/questions/14723578/phpbb3-forum-feed-on-external-page-for-non-authenticated-users
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');
$search_limit = 5;
// ----- Change between HERE -----
$posts_ary = array(
'SELECT' => 'p.*, t.*, u.username, u.user_colour',
'FROM' => array(
POSTS_TABLE => 'p',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(USERS_TABLE => 'u'),
'ON' => 'u.user_id = p.poster_id'
),
array(
'FROM' => array(TOPICS_TABLE => 't'),
'ON' => 'p.topic_id = t.topic_id'
),
),
'WHERE' => $db->sql_in_set('t.forum_id', array_keys($auth->acl_getf('f_read', true))) . '
AND t.topic_status <> ' . ITEM_MOVED . '
AND t.topic_approved = 1',
'ORDER_BY' => 'p.post_id DESC',
);
$posts = $db->sql_build_query('SELECT', $posts_ary);
$posts_result = $db->sql_query_limit($posts, $search_limit);
while( $posts_row = $db->sql_fetchrow($posts_result) )
{
$topic_title = $posts_row['topic_title'];
$post_author = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_colour']);
$post_date = $user->format_date($posts_row['post_time']);
$post_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $posts_row['post_id'] . "#p" . $posts_row['post_id']);
$post_text = nl2br($posts_row['post_text']);
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);
$post_text = smiley_text($post_text);
$template->assign_block_vars('announcements', array(
'TOPIC_TITLE' => censor_text($topic_title),
'POST_AUTHOR' => $post_author,
'POST_DATE' => $post_date,
'POST_LINK' => $post_link,
'POST_TEXT' => censor_text($post_text),
));
}
// --- and HERE ---
page_header('External page');
$template->set_filenames(array(
'body' => 'external_body.html'
));
page_footer();
?>
如果您不想在论坛的根目录中进行此操作,则需要修改此行以使用相应的路径指向论坛的根目录:
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
指示更改代码块的位置的两行是显示内容的核心。上面,我已经从您提供的链接发布了Example 4。从其他示例中替换整个代码块也可以。
最后,当您进行模板更改时,可能需要从ACP中清除缓存。