Create a New Page in phpBB2

Submitted by Reiji Kurosaky, Feb 2007.
Page: 1
Pages: [1] [2] [3] [4]
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:
Code: (tos.php)
  1. <?php  
  2. /*  
  3. * Filename: tos.php  
  4. * Version: 1.0.0  
  5. * Author: xxx  
  6. */  
  7.  
  8. define('IN_PHPBB', true);  
  9. $phpbb_root_path = './';  
  10. include($phpbb_root_path . 'extension.inc');  
  11. include($phpbb_root_path . 'common.'.$phpEx);  
  12.  
  13. //  
  14. // Start session management  
  15. //  
  16. $userdata = session_pagestart($user_ip, PAGE_INDEX);  
  17. // 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.  
  18. init_userprefs($userdata);  
  19. //  
  20. // End session management  
  21. //  
  22.  
  23. $page_title = 'OWN TITLE';  
  24. $lang_file = 'LANG FILENAME HERE WITHOUT EXTENSION';  
  25. include($phpbb_root_path . 'includes/page_header.'.$phpEx);  
  26. include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/' . $lang_file . '.'.$phpEx);  
  27.  
  28. $template->set_filenames(array(  
  29.        'body' => 'PAGENAME.tpl') // Your template name.  
  30. );  
  31.  
  32. $template->pparse('body');  
  33. include($phpbb_root_path . 'includes/page_tail.'.$phpEx);  
  34.  
  35. ?> 
Letīs explain this code:
Code:
  1. define('IN_PHPBB', true);  
  2. $phpbb_root_path = './';  
  3. include($phpbb_root_path . 'extension.inc');  
  4. 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:
  1. //  
  2. // Start session management  
  3. //  
  4. $userdata = session_pagestart($user_ip, PAGE_INDEX);  
  5. // 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.  
  6. init_userprefs($userdata);  
  7. //  
  8. // End session management  
  9. // 
This is self explanatory, it manage the session of the user.
Code:
  1. $page_title = 'OWN TITLE';  
  2. $lang_file = 'LANG FILENAME HERE WITHOUT EXTENSION';  
  3. include($phpbb_root_path . 'includes/page_header.'.$phpEx);  
  4. 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:
  1. $template->set_filenames(array(  
  2.        'body' => 'PAGENAME.tpl') // Your template name.  
  3. );  
This include the template page of your tos page.
Code:
  1. $template->pparse('body');  
  2. include($phpbb_root_path . 'includes/page_tail.'.$phpEx); 
With this code you include the footer of the page.
Page: 1
Pages: [1] [2] [3] [4]

Share this tutorial

If you want to show this tutorial to someone else please use following code to link to this tutorial:
HTML Link:
Forum BBCode:
Content of this tutorial may not be published anywhere else without author's permission. Please link to this page instead.