I have a custom portal that was made for phpBB 3.0.x and I need to convert it to phpBB 3.1.
Code: Select all
$sql = 'SELECT topic_id, forum_id, topic_poster, topic_first_poster_colour, topic_title, topic_first_poster_name, topic_time FROM ' . TOPICS_TABLE . ' WHERE forum_id != 12 AND forum_id != 3 ORDER BY topic_replies DESC, topic_time DESC';
$result = $db->sql_query_limit($sql, $portal_config['topics']);
while ($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('latest_hot_topics', array(
'TOPIC_TITLE' => $row['topic_title'],
'TOPIC_LINK' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
'TOPIC_REPLIES' => $this->get_topic_replies($row['topic_id']),
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
));
}
private function get_topic_replies($topic_id)
{
global $db;
$sql = 'SELECT COUNT(post_id) AS post_count FROM ' . POSTS_TABLE . ' WHERE ' . POSTS_TABLE . '.topic_id = ' . $topic_id . '';
$result = $db->sql_query($sql);
$post_count = (int)$db->sql_fetchfield('post_count');
$db->sql_freeresult($result);
return $post_count - 1;
}