2013-02-06 62 views
1

我正在嘗試將論壇Feeds的PHPBB3論壇整合到外部FrontPage中。PHPBB3針對未經過身份驗證的用戶的外部頁面上的論壇Feed

爲此,我正在使用從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" 

該用戶是在來賓組,其類型是默認IGNORE。 我試着將user_type設置爲0 = NORMAL - 無濟於事。

作爲PHPBB3論壇上的普通訪問者,我可以閱讀所有開放論壇,我不知道 爲什麼這個通用訪客用戶無法訪問論壇。

更新和sollution

我要感謝你再次給我帶來了正軌答案。 我會不斷地searchted在PHPBBs用戶管理 時,我原來的錯誤只是一個愚蠢的複製/粘貼問題的深處sollution ...

$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

如果需要更多信息來了解問題,請問我。目前唯一運行的代碼是上面鏈接的代碼,而默認設置是未修改的phpbb3論壇。 – elfwyn

回答

1

空白頁面是因爲您的style/prosilver/templates目錄中沒有external_body.html文件。

非常基本的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中的緩存。

相關問題