我正在使用phpBB创建一个简单的社区。所以,我想创建一个costum网站,我想在其中显示某些组的成员。
代码是我第一次尝试创建costum网站。
我有members.php
<?php
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);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// Inits Languagefile
page_header('test');
// Groups that should displayed
$group_ids = array(
5,
9,
);
// Get Groups from Database
$sql = 'SELECT group_id, group_name, group_desc FROM ' . GROUPS_TABLE . ' WHERE ' . $db->sql_in_set('group_id', $group_ids);
$result = $db->sql_query($sql);
// Write Data for each Group
while ($row = $db->sql_fetchrow($result)) {
$template->assign_block_vars('unit', array(
'GROUPNAME' => $row['group_name'],
'DESCRIPTION' => $row['group_desc'],
));
// Get Groupmembers from Database
$sqlusers = 'SELECT user_id FROM ' . USER_GROUP_TABLE . ' WHERE group_id = ' . $row['group_id'];
$users = $db->sql_query($sqlusers);
// Get User from Database
while ($user = $db->sql_fetchrow($users)) {
$sql_arr = array(
'SELECT' => 'u.user_id, u.username, u.user_avatar, r.rank_title, r.rank_image',
'FROM' => array(
USERS_TABLE => 'u',
RANKS_TABLE => 'r'
),
'WHERE' => 'u.user_id = ' . $user['user_id'] . ' AND u.user_rank = r.rank_id',
);
$sqluserdata = $db->sql_build_query('SELECT', $sql_arr);
$userdata = $db->sql_query($sqluserdata);
// Write Data for each User
while($single = $db->sql_fetchrow($userdata)) {
$template->assign_block_vars('unit.member', array(
'USERID' => $single['user_id'],
'USERNAME' => $single['username'],
'AVATAR' => $single['user_avatar'],
'RANK' => $single['rank_title'],
'RANGIMAGE' => $single['rank_image'],
));
}
$db->sql_freeresult($userdata);
}
$db->sql_freeresult($users);
}
$db->sql_freeresult($result);
// Load Template
$template->set_filenames(array(
'body' => 'members.html',
));
// End Controller
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
?>
导致样式/ * / members.html:
<!-- INCLUDE overall_header.html -->
<div id="sub-header">
<div class="chunk">
<div class="sub-header-title">
<h2 class="titlespace">Mitglieder</h2>
</div>
</div>
</div>
<div class="background-main">
<div class="chunk">
<!-- BEGIN unit -->
<div class="unit">
<h3>{unit.GROUPNAME}</h3>
<p>{unit.DESCR}</p>
<!-- BEGIN unit.member -->
<div class="unitmember" style="background-color:red;">
<p>{unit.member.USERNAME}</p>
<p>{unit.member.AVATAR}</p>
<p>{unit.member.USERID}</p>
<p>{unit.member.RANK}</p>
<p>{unit.member.RANKIMAGE}</p>
</div>
<!-- END unit.member -->
</div>
<!-- END unit -->
</div>
</div>
<!-- INCLUDE jumpbox.html -->
<!-- INCLUDE overall_footer.html -->
我通过var_dump测试了数据输出,每次都很好......但是每当我解析模板时,它都会抛出这个错误:
“可捕获的致命错误:传递给phpbb_generate_debug_output()的参数4必须是phpbb \ user的实例,给定布尔值,在5431行的C:\ xampp \ htdocs \ jgzga \ includes \ functions.php中调用,并在C中定义:\ xampp \ htdocs \ jgzga \ includes \ functions.php on line 5343“
我从未接触过phpbb的核心文件...所以...也许你们中的一些人可以帮助我。 ;)
答案 0 :(得分:0)