I uploaded a 'Hello World' example to my own server. This is meant to be a bit more practical of an example, and includes the following:
Features wrote: - Integration with any existing forum session
- Ability to login if not already logged in
- Login will persist should you then visit the forum, no need to login a second time
- Utilizing phpbb's powerful template engine.
I am providing this simply because this is the end I am working towards: A site utilizing this engine, which integrates with a forum powered by phpbb. To accomplish this I had to make some changes, and I have a few more planned:
Future Enhancements wrote: - Validation Page doesn't currently use layout engine. Remove page entierly, have the login redirect to itself, build code in to handle this
- Go through layout class and remove cache references as i'm not caching layouts, also remove unnecessary or unused functions
- Rename functions to fit new class name: layout (name was changed so it wouldn't conflict with the template class of phpbb)
- Currently adding common.php to index.php so that session management will work (as the example in
this thread detailed. Instead, go through and find the individual classes and functions that are required so that we aren't bloating the file with extra classes, code and functions that aren't needed just to integrate a session.
If you're interested in just seeing how I modified some of the files to fit the above:
index.php
Code: Select all
<?php
define('IN_PHPBB', true);
$site_root_path = './';
$phpbb_root_path = '../forum/';
$phpEx = 'php';
$user = '';
include('class/layout.php');
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// Build template
$layout = new template();
$layout->set_custom_template('layout', 'default');
$layout->assign_vars(array(
'U_IS_REGISTERED' => ($user->data['is_registered']) ? true : false,
'U_USERNAME' => $user->data['username']
));
$layout->set_filenames(array(
'body' => 'index_body.html'
));
$layout->display('body');
?>
index_body.html
Code: Select all
<!-- INCLUDE header.html -->
<!-- IF U_IS_REGISTERED -->
<div>
Welcome Back {U_USERNAME}
</div>
<!-- ELSE -->
<div>
<form method="POST" action="validate.php">
<p>
Username: <input type="text" name="username" size="40"><br />
Password: <input type="password" name="password" size="40"><br />
<input type="submit" value="Submit" name="login">
</p>
</form>
</div>
<!-- ENDIF -->
<!-- INCLUDE footer.html -->
layout.php
- Modified class name
- Changed the name of a variable reference from $phpbb_root_path to instead reference $site_root_path. This is needed for integration of the forum files with the standalone template engine.
Final notes:
- My site is setup as follows:
/
/forum (contains the forum)
/test (contains the code above)
You will need to either match that structure, or modify the root variables accordingly. Hope someone finds this of some use.
Zip File