Website Integration

Discussion forum for MOD Writers regarding MOD Development.
Locked
NarusegawaUK
Registered User
Posts: 4
Joined: Fri Feb 05, 2010 9:09 pm

Website Integration

Post by NarusegawaUK »

Hi, I've been trying to convert my old phpBB2 code to work with phpBB3 but having no success sadly.

Here is my original version 2 code that works a treat. templates/news_announcements.tpl is my own template file outside of phpBB2's folder.

Code: Select all

<?php
$sql = "select t.topic_time, t.topic_title
from phpBB_topics t
where t.forum_id = 1 and t.topic_type = 2
order by t.topic_id desc
limit 0,3";

if ( !($result = $db->sql_query($sql)) )
{
    die("Could not query database".$db->sql_error());
}
while ( $row = $db->sql_fetchrow($result) )
{
    $template->set_filenames(array(
        'announcements' => 'templates/news_announcements.tpl')
    );
    $template->assign_vars(array(
                                                                'TITLE' => $row['topic_title'],
                                                                'DATETIME' => date('M dS, Y',$row['topic_time'])
                                                            )
                                                );
    $template->pparse('announcements');

}
$db->sql_freeresult($result);
?>
I've tried to move over to phpBB3 but this code only returns me a single topic (phpBB2 code shows all 3, and the SQL returns all 3 still)

Code: Select all

<?php
$sql = "select t.topic_time, t.topic_title
from phpBB3_topics t
where t.forum_id = 1 and t.topic_type = 2
order by t.topic_id desc
limit 0,3";

if ( !($result = $db->sql_query($sql)) )
{
    die("Could not query database".$db->sql_error());
}
while ( $row = $db->sql_fetchrow($result) )
{
    $template->set_filenames(array(
        'announcements' => '../../../../templates/news_announcements.tpl')
    );
    $template->assign_vars(array(
                                                                'TITLE' => $row['topic_title'],
                                                                'DATETIME' => date('M dS, Y',$row['topic_time'])
                                                            )
                                                );
    $template->display('announcements');

}
$db->sql_freeresult($result);
?>
Any idea what's going wrong? As I say the only problem is that it only display one topic instead of the 3 it should.

Thanks in advance
Last edited by NarusegawaUK on Fri Feb 05, 2010 10:31 pm, edited 1 time in total.
comkidwizzer3
Registered User
Posts: 375
Joined: Fri Jul 13, 2007 8:24 am
Location: $user->data['user_location'];
Contact:

Re: Website Integration

Post by comkidwizzer3 »

Code: Select all

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(); 
Is what you need to add under the <?php and above all the other code. ;)
~My MODs~
Login After Register - v1.0.0 | Custom Ranks MOD - RC

~!Hasher!~
NarusegawaUK
Registered User
Posts: 4
Joined: Fri Feb 05, 2010 9:09 pm

Re: Website Integration

Post by NarusegawaUK »

Already have that above this entire block. With 2 additional includes.

Code: Select all

include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx); 
Hasn't really changed that much from phpBB2 in this respect.
Locked

Return to “[3.0.x] MOD Writers Discussion”