[Tutorial] Integrate your website around phpBB3

How-to's, little tricks, tutorials, code examples (snippets) and read-me's.

Re: [Tutorial] Integrate your website around phpBB3

Postby topdown » 11 Nov 2010, 19:17

You just have to define these in each new page controller

Code: Select all
define('IN_PHPBB'true);  //Typical phpBB security check to make sure this file is part of phpBB
define('ROOT_PATH''./../');  //This is the path to the root of the site (where your index.php or common.php is) 


Then ROOT_PATH is used throughout the rest of the includes and code eg.
include(ROOT_PATH . 'common.' . $phpEx);
Do not PM me for Support unless I give permission in a post......PM's only help one, posts help everyone !
User avatar
topdown    
STG Styles Leader
STG Styles Leader
 
Posts: 3022
Joined: 01 Oct 2007, 22:56
Location: Handyman's harddrive
Favorite Team: STG Teams
Gender: Male
phpBB Knowledge: 9


Re: [Tutorial] Integrate your website around phpBB3

Postby stitch626 » 11 Nov 2010, 21:18

Thanks Jeff but I think I am just to stupid or PLC Programming oriented to understand this php crap. Just frustrating. :banghead:

Maybe I'll hire someone to get this working for me.
User avatar
stitch626    
STG Moderator Leader
STG Moderator Leader
 
Posts: 3185
Joined: 08 Feb 2007, 20:47
Location: Michigan
Favorite Team: Detroit Red Wings
Gender: Male
phpBB Knowledge: 7

Re: [Tutorial] Integrate your website around phpBB3

Postby topdown » 11 Nov 2010, 21:23

What are you setting up?
What is the problem?
Are there errors reporting?
Do not PM me for Support unless I give permission in a post......PM's only help one, posts help everyone !
User avatar
topdown    
STG Styles Leader
STG Styles Leader
 
Posts: 3022
Joined: 01 Oct 2007, 22:56
Location: Handyman's harddrive
Favorite Team: STG Teams
Gender: Male
phpBB Knowledge: 9

Re: [Tutorial] Integrate your website around phpBB3

Postby stitch626 » 11 Nov 2010, 21:55

Jeff,
I am trying to hook my html site into phpBB but I don't know if I need a php file for each html file. Not sure what a controller page is. I don;t know the difference between index.php and common.php. Do I need both of them?

This is what I attempted but all I got was unable to open stream bla bla bla no such file in blalblaq blaaaaaaa.

Code: Select all
<?php
    /**
    *
    * @author David Lewis ( http://startrekguide.com ) Highway of Life
    * @package STG
    * @version $Id: common.php 165 2007-12-23 05:21:41Z Highway of Life $
    * @copyright (c) 2007 Star Trek Guide Group
    *
    */

    if (!defined('IN_PHPBB') || !defined('ROOT_PATH'))
    {
        exit;
    }

    /**
     * @ignore
     */
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : ROOT_PATH . 'messageboard/';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
    include(ROOT_PATH . 'includes/functions_website.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);

    // void setup ([ $lang_set = false], [ $style = false])
    // language and style setup, we?ll use $style = 1 (prosilver)
    $user->setup(false, 1);

    // set your custom template path
    // void set_custom_template ( $template_path,  $template_name)
    $template->set_custom_template(ROOT_PATH . 'template', 'website');

    // Set some basic (global) template variables
    $template->assign_vars(array(
        'U_WEBSITE_STYLESHEET'    => ROOT_PATH . 'theme/stylesheet.css',
        'U_HOME'                => append_sid(ROOT_PATH),
        'U_FORUM'                => append_sid($phpbb_root_path),
    ));

    ?>


I have like 7 pages so do I need 7 php files one for each one? This roo_path is throwing me off too.
User avatar
stitch626    
STG Moderator Leader
STG Moderator Leader
 
Posts: 3185
Joined: 08 Feb 2007, 20:47
Location: Michigan
Favorite Team: Detroit Red Wings
Gender: Male
phpBB Knowledge: 7

Re: [Tutorial] Integrate your website around phpBB3

Postby topdown » 11 Nov 2010, 22:51

You need at minimum a controller file for each, eg. index.php, home.php, about.php
Or you can use one index.php controller with a switch for templates eg. index.php?page=about

For SEO purposes it is better to use the first and name the controller relative to the page eg. typicalseason.php
The common.php just links it to the phpBB system so you can run it externally and minimize some other phpBB calls.

What it comes down to it, what is the purpose or reason for you to do this?
There are a lot of ways to do it and all for different reasons and results.

All the ROOT_PATH is doing is defining the path to the site (not forum part)
Do not PM me for Support unless I give permission in a post......PM's only help one, posts help everyone !
User avatar
topdown    
STG Styles Leader
STG Styles Leader
 
Posts: 3022
Joined: 01 Oct 2007, 22:56
Location: Handyman's harddrive
Favorite Team: STG Teams
Gender: Male
phpBB Knowledge: 9

Re: [Tutorial] Integrate your website around phpBB3

Postby stitch626 » 12 Nov 2010, 05:58

Ok this does clear things up quite a bit. I think I have a better understanding. When you say

"All the ROOT_PATH is doing is defining the path to the site (not forum part)"

So does this mean Y should have this?
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : ROOT_PATH . '/';


Thanks for your help.
User avatar
stitch626    
STG Moderator Leader
STG Moderator Leader
 
Posts: 3185
Joined: 08 Feb 2007, 20:47
Location: Michigan
Favorite Team: Detroit Red Wings
Gender: Male
phpBB Knowledge: 7

Re: [Tutorial] Integrate your website around phpBB3

Postby topdown » 12 Nov 2010, 13:14

Code: Select all
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : ROOT_PATH . '/';


Is just handling the assignment of $phpbb_root_path

The code above is the same as
Code: Select all
if(defined('PHPBB_ROOT_PATH'))
{
    
$phpbb_root_path PHPBB_ROOT_PATH;
}
else
{
    
$phpbb_root_path ROOT_PATH '/';


So IF PHPBB_ROOT_PATH is defined $phpbb_root_path will be set to the value of PHPBB_ROOT_PATH
ELSE
if its not defined $phpbb_root_path will equal the value of ROOT_PATH plus a trailing slash '/'
Do not PM me for Support unless I give permission in a post......PM's only help one, posts help everyone !
User avatar
topdown    
STG Styles Leader
STG Styles Leader
 
Posts: 3022
Joined: 01 Oct 2007, 22:56
Location: Handyman's harddrive
Favorite Team: STG Teams
Gender: Male
phpBB Knowledge: 9

Re: [Tutorial] Integrate your website around phpBB3

Postby calfire » 27 Nov 2010, 18:59

I am building a new phpBB3 site in a development environment using WAMP (localhost). I am limiting the Board to one style only = "JBlue". I started with a clean version of JBlue and I have added three of my own pages into the phpBB3 site. Each one has an html template file in the JBlue Styles folders and a php configuration file in the bulletin board root folder (with index.php). Everything is working great except one little thing.

Everytime I navigate to one of the pages that I have added, the session ID is dropped from the browser link. When I go back to the board index I am logged out. I don't want the user to have to log back in after navigating to the new pages I am adding.

The filepath in the development environment I am using is C:\calfire\discuss\phpBB3\. When the new site is published the domain will be http://www.calfire.org

Here is the code for the template file of my photos page (photos_body.html).
Spoiler:
Code: Select all
<!-- INCLUDE overall_header.html -->
<h2>Photos</h2>
<div class="panel">
   <div class="inner">
      <table class="photopage" width="70%">
     <tr height="50px">
      <td width="40%" class="photoframe">
         <p>
         Our Member's Photo Album page is under construction.
         </p>
      </td>
      <td width="40%" class="photoframe">Sort Options
      </td>
      <td width="20%" class="photoframe">
      <p>Album Menus</p>
      <p>Search Options</p>
      </td>
      </tr>
     <tr height="150px">
      <td class="photoframe">
      Picture Frame 1
      </td>
      <td class="photoframe">Picture Frame 2
      </td>
      <td class="photoframe">Unassigned
      </td>
      </tr>
     </table>
   </div>
</div>
<!-- INCLUDE jumpbox.html -->
<!-- INCLUDE overall_footer.html -->

Here is the code for the php file of my Photos page (photos.php).
Spoiler:
Code: Select all
<?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();

page_header('Photos');

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

make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
?>

I have tried changing the phpbb_root_path...but every time I change it my new pages will no longer load, I just get a blank screen. The new pages only display when the phpbb_root_path is './'
calfire    
Crewman
Crewman
 
Posts: 1
Joined: 27 Nov 2010, 18:04
Gender: Male
phpBB Knowledge: 4

Re: [Tutorial] Integrate your website around phpBB3

Postby idontwantausername » 16 Aug 2011, 22:36

Hey cheers for this tutorial

I've got everything up and working, all is good. Just wondering how I can set each page to follow a user's chosen style.

So basically if they use the subsilver2 style I want the entire site (including error pages) to show up in subsilver2 style

cheers
idontwantausername
Cadet I
Cadet I
 
Posts: 11
Joined: 15 Nov 2008, 09:53
Gender: Male

Re: [Tutorial] Integrate your website around phpBB3

Postby topdown » 17 Aug 2011, 02:33

This is not really setup to function that way.
I would have to go through it and see what can be done to accomplish this.
Do not PM me for Support unless I give permission in a post......PM's only help one, posts help everyone !
User avatar
topdown    
STG Styles Leader
STG Styles Leader
 
Posts: 3022
Joined: 01 Oct 2007, 22:56
Location: Handyman's harddrive
Favorite Team: STG Teams
Gender: Male
phpBB Knowledge: 9

Previous

Return to Tutorials and How-Tos

Who is online

Users browsing this forum: Magpie Crawler and 4 guests