Create a New Page in phpBB2
Hello,
First of all, this tutorial is an extension of the one writed by DoobDee here.
Now, let´s proceed to the tutorial, to make an example, I´ll teach you how to create a TOS (Terms of Services) page.
First of all, let´s start with the PHP file:
First of all, this tutorial is an extension of the one writed by DoobDee here.
Now, let´s proceed to the tutorial, to make an example, I´ll teach you how to create a TOS (Terms of Services) page.
First of all, let´s start with the PHP file:
Code: (tos.php)
- /*
 - * Filename: tos.php
 - * Version: 1.0.0
 - * Author: xxx
 - */
Â
Â- define(‘IN_PHPBB’, true);
 - $phpbb_root_path = ‘./’;
 - include($phpbb_root_path . ‘extension.inc’);
 - include($phpbb_root_path . ‘common.’.$phpEx);
Â
Â- //
 - // Start session management
 - //
 - $userdata = session_pagestart($user_ip, PAGE_INDEX);
 - // You can change the page you are on, but this page must be defined in includes/page_header.php, viewonline.php, admin/index.php and includes/constants.php.  For the purpose of the tutorial we will leave it as the index page.
 - init_userprefs($userdata);
 - //
 - // End session management
 - //
Â
Â- $page_title = ‘OWN TITLE‘;
 - $lang_file = ‘LANG FILENAME HERE WITHOUT EXTENSION‘;
 - include($phpbb_root_path . ‘includes/page_header.’.$phpEx);
 - include($phpbb_root_path . ‘language/lang_’ . $board_config[‘default_lang’] . ‘/’ . $lang_file . ‘.’.$phpEx);
Â
Â- $template->set_filenames(array(
 -     ‘body’ => ‘PAGENAME.tpl‘) // Your template name.
 - );
Â
Â- $template->pparse(‘body’);
 - include($phpbb_root_path . ‘includes/page_tail.’.$phpEx);
Â
Â- ?>Â
Let´s explain this code:
Code:
- define(‘IN_PHPBB’, true);
 - $phpbb_root_path = ‘./’;
 - include($phpbb_root_path . ‘extension.inc’);
 - include($phpbb_root_path . ‘common.’.$phpEx); Â
This is included in all php pages of phpBB, it defines the path of the forum and includes the extension file phpBB uses and the common expresions of phpBB.
Code:
- //
 - // Start session management
 - //
 - $userdata = session_pagestart($user_ip, PAGE_INDEX);
 - // You can change the page you are on, but this page must be defined in includes/page_header.php, viewonline.php, admin/index.php and includes/constants.php.  For the purpose of the tutorial we will leave it as the index page.
 - init_userprefs($userdata);
 - //
 - // End session management
 - //Â
This is self explanatory, it manage the session of the user.
Code:
- $page_title = ‘OWN TITLE‘;
 - $lang_file = ‘LANG FILENAME HERE WITHOUT EXTENSION‘;
 - include($phpbb_root_path . ‘includes/page_header.’.$phpEx);
 - include($phpbb_root_path . ‘language/lang_’ . $board_config[‘default_lang’] . ‘/’ . $lang_file . ‘.’.$phpEx);Â
This is configurable, you can change here the language name and the page title, then it includes the phpBB header and the language file used.
Code:
- $template->set_filenames(array(
 -     ‘body’ => ‘PAGENAME.tpl‘) // Your template name.
 - );
Â
This include the template page of your tos page.
Code:
- $template->pparse(‘body’);
 - include($phpbb_root_path . ‘includes/page_tail.’.$phpEx);Â
With this code you include the footer of the page.
Share this tutorial
Â