CMSMS & PHPBB Forum [SOLVED]

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
peterbisset

CMSMS & PHPBB Forum [SOLVED]

Post by peterbisset »

Hi,

I am trying to build a website using CMSMS with a forum powered by PHPBB (actually just noticed that the cmsmadesimple.org website has the same setup!). I have installed both fine but want to be able to display the latest forum posts on the homepage. I managed to find a setup that enables me to do this on a php page, however when I copy this setup into CMSMS the code does not run correctly.

Here is the site homepage with the error: http://www.bladerunner-2.com/

Here is the static php test page that works: http://www.bladerunner-2.com/test.php

Here is the PHPBB code I am trying to import from this php test page into CMSMS:

Code: Select all

<?php
/*
* home.php
* Description: example file for displaying latest posts and topics
* by battye (for phpBB.com MOD Team)
* September 29, 2009
*/

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/';
$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;

$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),
));
}

page_header('External page');

$template->set_filenames(array(
'body' => 'external_body.html'
));

page_footer();
?> 
Here is my system information:

----------------------------------------------

Cms Version: 1.11.4

Installed Modules:

CMSMailer: 5.2.1
CMSPrinting: 1.0.3
FileManager: 1.4.3
MenuManager: 1.8.5
MicroTiny: 1.2.5
ModuleManager: 1.5.5
News: 2.12.10
Search: 1.7.7
ThemeManager: 1.1.7
Gallery: 1.6
CGSimpleSmarty: 1.6
CGExtensions: 1.32.2
CGFeedback: 1.5.11


Config Information:

php_memory_limit:
process_whole_template:
output_compression:
max_upload_size: 40000000
url_rewriting: mod_rewrite
page_extension:
query_var: page
image_manipulation_prog: GD
auto_alias_content: true
locale:
default_encoding: utf-8
admin_encoding: utf-8
set_names: true


Php Information:

phpversion: 5.4.12
md5_function: On (True)
gd_version: 2
tempnam_function: On (True)
magic_quotes_runtime: Off (False)
E_STRICT: 0
E_DEPRECATED: 0
memory_limit: 90M
max_execution_time: 50000
output_buffering: 0
safe_mode: Off (False)
file_uploads: On (True)
post_max_size: 8M
upload_max_filesize: 40M
session_save_path: /tmp (1777)
session_use_cookies: On (True)
xml_function: On (True)
xmlreader_class: On (True)


Server Information:

Server Api: cgi-fcgi
Server Db Type: MySQL (mysqli)
Server Db Version: 5.1.67
Server Db Grants: Found a "GRANT ALL" statement that appears to be suitable


----------------------------------------------
I have tried using a UDT to import the code however I get the same result, can someone please help?

Thanks in advance.
Last edited by peterbisset on Thu Mar 28, 2013 11:31 am, edited 1 time in total.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1967
Joined: Mon Jan 29, 2007 4:47 pm

Re: CMSMS & PHPBB Forum

Post by Jo Morg »

1st, you can't run php directly from a CMSMS template or page, as it will be parsed by SMARTY and it is not supported (and the inclusion of {php}...{/php} tags are deprecated).
2nd, if you paste the code into an UDT, do it without the enclosing tags (i.e.: <?php ...... ?>) and it would probably work if the paths to the included files are correct.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
peterbisset

Re: CMSMS & PHPBB Forum

Post by peterbisset »

Thanks for getting back to me.

I didn't realise that you can't run php directly in the template as I have never tried it before.

I created a UDT without the closing tags but unfortunately it still didn't work, the paths are correct as they are exactly the same as the test page I created which is in the same folder location as the homepage.

Any other ideas?
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1967
Joined: Mon Jan 29, 2007 4:47 pm

Re: CMSMS & PHPBB Forum

Post by Jo Morg »

peterbisset wrote:I created a UDT without the closing tags but unfortunately it still didn't work, the paths are correct as they are exactly the same as the test page I created which is in the same folder location as the homepage.

Any other ideas?
If the UDT allowed to save then it's not an obvious error. It must be more of a bug. But there are a few problems that come to mind that are not easy to fix. CMSMS and phpBB run in a object oriented context. That sometimes raises lots of problems when trying to do a simple integration. I don't believe this:

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/';
$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')
will work in cmsms context...
You need to do some serious debugging in order to know if the objects exist, and are what they should be when you call a method as $user->session_begin().
Now, as a suggestion, why not use the forums RSS feed and a CMSMS module capable of reading them? There is one or two at the forge IIRC... :)
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
peterbisset

Re: CMSMS & PHPBB Forum

Post by peterbisset »

Thanks for your suggestion, as my PHP knowledge is nowhere near adequate I think I will look at going the RSS route.

As a matter of interest I see that the the homepage for http://www.cmsmadesimple.org has a recent posts section and they are using the same forum software as me, would be fascinated to know how they achieved it...
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1967
Joined: Mon Jan 29, 2007 4:47 pm

Re: CMSMS & PHPBB Forum

Post by Jo Morg »

Not sure, but I'm willing to bet it's RSS. I believe it's easy and better to customize.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
peterbisset

Re: CMSMS & PHPBB Forum

Post by peterbisset »

Just an update on this for anyone who is interested in integrating a forum with CMSMS I have successfully integrated the rss feed from PHPBB with my site using the RSS2HTML module.

It's as simple as getting the url for the feed from the forum, in this case "../forum/feed.php", creating a new feed and then embedding the {RSS2HTML feed='Your feed'} tag into where ever you want the "latest posts" section to be.
Locked

Return to “Modules/Add-Ons”