creating blank phpbb3 page

Creating a blank phpBB3 page

Submitted by DoubleJ, Dec 2007.
Page: 1

Pages: [1] [2]

1. Creating the php file

First of all we will need to create a php file, which will include all nessecary phpBB3 files which are used to create our sessions, templating system and other things.

We will start of by creating a ‘page.php’ file. At the top of the page, we will first define basic constants, and include basic files.

Code:
  1. /*
     
  2. *    phpBB3 blank example page.
     
  3. */
     

  4.  
  5. define(‘IN_PHPBB’, true);
     
  6. $phpbb_root_path = (defined(‘PHPBB_ROOT_PATH’)) ? PHPBB_ROOT_PATH : ‘./’;
     
  7. $phpEx = substr(strrchr(__FILE__, ‘.’), 1);
     
  8. include($phpbb_root_path . ‘common.’ . $phpEx); 
the common.php file, will enable the following things for phpBB:

  • Caching system

  • Database system

  • Templating system

  • Auth system

  • User/session system

Now that all basic things are available to us, we will need to start the user’s session, so we can identify our user.

Code:
  1. // Start session management
     
  2. $user->session_begin();
     
  3. $auth->acl($user->data);
     
  4. $user->setup(‘common’); 
The $user->setup(‘common’); function, is used to setup the basic language file of the page, in this case common.php language file, you can also replace ‘common’ with your own language file.



Additional language files for your page can be added by using the following line of code, this example will include the ‘page.php’ language file.

Code:
  1. // include page language file
     
  2. $user->add_lang(‘page’); 
Finally we want to have all basic template variables available, which we can use on each page. These are generated by the page_header(‘title’); function. ‘title’ will be set as the title of your page, the {PAGE_TITLE} variable. phpBB3 uses a function rather the a file to generate the header/basic vars. The header template file is include within the template file, rather then the php file, which gives style authors more control about which header they use.
Code:
  1. page_header($user->lang[‘PAGE_TITLE’]); 
Now you can start your own code from here.

When you have finished all of your own code, don’t forget to set a template file, which this page will use. You can do this by using the template class of phpBB, using the following command:
Code:
  1. $template->set_filenames(array(
     
  2.    ‘body’    => ‘your_page_body.html’
     
  3. )); 
We called our template file ‘your_page_body.html’.



Finally, we will need to finish the page, and say it has to be parsed. phpBB3 does this with the page_footer() function.
Code:
  1. // parse page:
     
  2. page_footer();
     
  3. ?> 
Now you are done with your page.php file, the entire file should look something like this:
Code:
  1. /*
     
  2. *    phpBB3 blank example page.
     
  3. */
     

  4.  
  5. define(‘IN_PHPBB’, true);
     
  6. $phpbb_root_path = (defined(‘PHPBB_ROOT_PATH’)) ? PHPBB_ROOT_PATH : ‘./’;
     
  7. $phpEx = substr(strrchr(__FILE__, ‘.’), 1);
     
  8. include($phpbb_root_path . ‘common.’ . $phpEx);
     
  9. // Start session management
     
  10. $user->session_begin();
     
  11. $auth->acl($user->data);
     
  12. $user->setup(‘common’);
     
  13. // include page language file
     
  14. $user->add_lang(‘page’);
     
  15. page_header($user->lang[‘PAGE_TITLE’]);
     

  16.  
  17. /*
     
  18.    Put your own code here
     
  19. */
     

  20.  
  21. $template->set_filenames(array(
     
  22.    ‘body’    => ‘your_page_body.html’
     
  23. ));
     
  24. // parse page:
     
  25. page_footer();
     
  26. ?> 
Page: 1

Pages: [1] [2]

Share this tutorial

If you want to show this tutorial to someone else please use following code to link to this tutorial:

HTML Link:
Creating a blank phpBB3 page” 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.