Creating php pages by using phpBB template?

The 2.0.x discussion forum has been locked; this will remain read-only. The 3.0.x discussion forum has been renamed phpBB Discussion.
Locked
slei
Registered User
Posts: 135
Joined: Sat Apr 06, 2002 6:44 am
Location: Canada
Contact:

Creating php pages by using phpBB template?

Post by slei »

Hi,
I am wondering whether i can create some .php pages outside of the phpBB folder but still using the phpBB templates. What i mean is those .php pages will use the same header and footer from the phpBB and use the same theme(fixed on using only one theme from phpBB)

Thanks
User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34459
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Post by A_Jelly_Doughnut »

You will need to include template.php, page_header.php & page_tail.php ( This may or may not work).
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish
User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun »

It works just fine. Here's a skeleton of what I use to do just this:

Code: Select all

<?php

// standard hack prevent
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

// standard session management
$userdata = session_pagestart($user_ip, PAGE_FAQ);
init_userprefs($userdata);

// set page title
$page_title = 'YOUR PAGE TITLE HERE';

// standard page header
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

// assign template
$template->set_filenames(array(
        'body' => 'YOUR_TEMPLATE_NAME_HERE.tpl')
);

$template->pparse('body');

// standard page footer
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>
That's all there is to it. Put your standard HTML content in the template file that you reference, pass any php variables (if you need to, in this sample I don't), and there you go. I use this basic code on several pages on my site, and it works great.

The only odd part is that anyone viewing a "custom" page shows up as "Viewing FAQ" in the "Who's online" area. That's because of the PAGE_FAQ entry up at the top. To make this work, you have to edit a few other files and set up various additional entries.

Dave
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image
slei
Registered User
Posts: 135
Joined: Sat Apr 06, 2002 6:44 am
Location: Canada
Contact:

Post by slei »

Thanks for your replies!

What if i want to put the page outside of the phpbb folder? Is it going to work? :)

Thanks
LifeIsPain
Former Team Member
Posts: 2148
Joined: Tue Oct 01, 2002 7:04 am
Location: Way Way Behind

Post by LifeIsPain »

Change:

Code: Select all

$phpbb_root_path = './';
to

Code: Select all

$phpbb_root_path = 'forum/';
I am pretty sure... or if not forum/ then use whatever the subdirectory is. Perhaps ../forum/ if that is the case you need.
LifeIsPain - one who needs to be smackedLife is pain, highness! Anyone who says differently is selling something.
User avatar
Dalgar
Registered User
Posts: 93
Joined: Mon May 27, 2002 2:09 am
Location: Minnesota
Contact:

Post by Dalgar »

or whatever the path is...not necessarily forums/
The Early Bird May Get The Worm But The Second Mouse Gets The Cheese.
Locked

Return to “2.0.x Discussion”