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)
- <?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.