Creating a blank phpBB3 page
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:
- <?php
- /*
- * phpBB3 blank example page.
- */
- define('IN_PHPBB', true);
- $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
- $phpEx = substr(strrchr(__FILE__, '.'), 1);
- 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
Code:
- // Start session management
- $user->session_begin();
- $auth->acl($user->data);
- $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.
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:
- // include page language file
- $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:
- 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:
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:
- $template->set_filenames(array(
- 'body' => 'your_page_body.html'
- ));
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.
Finally, we will need to finish the page, and say it has to be parsed. phpBB3 does this with the page_footer() function.
Code:
- // parse page:
- page_footer();
- ?>
Now you are done with your page.php file, the entire file should look something like this:
Code:
- <?php
- /*
- * phpBB3 blank example page.
- */
- define('IN_PHPBB', true);
- $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
- $phpEx = substr(strrchr(__FILE__, '.'), 1);
- include($phpbb_root_path . 'common.' . $phpEx);
- // Start session management
- $user->session_begin();
- $auth->acl($user->data);
- $user->setup('common');
- // include page language file
- $user->add_lang('page');
- page_header($user->lang['PAGE_TITLE']);
- /*
- Put your own code here
- */
- $template->set_filenames(array(
- 'body' => 'your_page_body.html'
- ));
- // parse page:
- page_footer();
- ?>