create a new page in phpbb2

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. /*
     
  2. * Filename: tos.php
     
  3. * Version: 1.0.0
     
  4. * Author: xxx
     
  5. */
     

  6.  
  7. define(‘IN_PHPBB’, true);
     
  8. $phpbb_root_path = ‘./’;
     
  9. include($phpbb_root_path . ‘extension.inc’);
     
  10. include($phpbb_root_path . ‘common.’.$phpEx);
     

  11.  
  12. //
     
  13. // Start session management
     
  14. //
     
  15. $userdata = session_pagestart($user_ip, PAGE_INDEX);
     
  16. // 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.
     
  17. init_userprefs($userdata);
     
  18. //
     
  19. // End session management
     
  20. //
     

  21.  
  22. $page_title = ‘OWN TITLE‘;
     
  23. $lang_file = ‘LANG FILENAME HERE WITHOUT EXTENSION‘;
     
  24. include($phpbb_root_path . ‘includes/page_header.’.$phpEx);
     
  25. include($phpbb_root_path . ‘language/lang_’ . $board_config[‘default_lang’] . ‘/’ . $lang_file . ‘.’.$phpEx);
     

  26.  
  27. $template->set_filenames(array(
     
  28.        ‘body’ => ‘PAGENAME.tpl‘) // Your template name.
     
  29. );
     

  30.  
  31. $template->pparse(‘body’);
     
  32. include($phpbb_root_path . ‘includes/page_tail.’.$phpEx);
     

  33.  
  34. ?> 

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:
Create a New Page in phpBB2” class=”text” onclick=”this.focus(); this.select();”/>
Forum BBCode:

Content of this tutorial may not be published anywhere else without author’s permission. Please link to this page instead.