Because there are no real tutorials that show you the complete way to integrate PHPBB3 forums with your website, this tutorial will show you how to progress through a few simple steps that will allow you to start a site like Unofficials.org – or at least the user integration part. =D We’re going to use the default PHPBB3 files for this integration tutorial. However, keep in mind that there are quite a few ways that we could integrate the forums with the site. So, without further adieu let us begin.
Step 1 – Install PHPBB3 in a directory. For the purposes of this tutorial, we’ll use “/forums”.
Step 2 – We’ll start the integration. Be sure to read all of the comments, as they explain what’s going on throughout the file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <?php define('IN_PHPBB', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : 'forums/'; // Please change this to match the path of your installation. $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); // This calls out the common PHPBB3 files, which we can use to easily verify users. include($phpbb_root_path . 'includes/functions_display.' . $phpEx); // This calls out the PHPBB3 functions, which we can use to manipulate users. $user->session_begin(); $auth->acl($user->data); $user->setup(); if(!$user->data["is_registered"]) // This means the user is not logged in. Display the following in quotes { die("You aren't logged in."); } $page = "Neato!"; if($user->data["is_registered"]) // This means the user is not logged in. Display the following in quotes { echo $page; } ?> |
Step 3 – Add your content! Just insert that file (once you’ve modified it to match the path of your PHPBB3 forums installation), in the body of your layout or template. Then, add the content you want logged in or logged out users to use in accordance with the comments.
That’s it. It’s really rather simple. However, the first time I did this it was as confusing as could be, and there are no real good tutorials that explain the steps fully. Please use this and enjoy.
Very nice. I’ve been looking for something like this for a long time.
This should be very useful to many people.
As soon as PHPbb will work for me, This will become very useful. Thanks John