August 23rd, 2010

phpBB3 Custom Pages

Making Basic Additional pages in PhpBB3 is fairly easy if you follow these instructions.

There are 3 basic files needed

  • HTML template
  • your php file, goes in the root of the forum
  • language definition file php

Lets start with the template

open notepad or a code editor of your choice (NOT WORD, OR ANY MS PRODUCT)

This is the basic code for a prosilver style using the panel bg2 classes with the link back to top arrow like in the topic_body.

Save this file as about_body.html

    <!-- INCLUDE overall_header.html -->
      <div class="panel bg2">
        <div class="inner"><span class="corners-top"><span></span></span>
            <h3>phpBB3 Custom Pages</h3>
            <p>Put your content here</p>
            <div class="back2top"><a href="#wrap" class="top" title="Top">Top</a></div>
        <span class="corners-bottom"><span></span></span>
        </div>
    </div>
    <!-- INCLUDE overall_footer.html -->

Next lets drive this page by making the php file

<?php
    /** 
    *
    * @name about.php
    * @version 1.11.26
    * @package phpBB validwebs.com about.php
    * @copyright (c) 2007 topdown, validwebs.com
    * @license http://opensource.org/licenses/gpl-license.php GNU Public License 
    *
    */
 
    // Note: If you would like to have a page in a different location than in the main phpBB3 directory
 
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    // Lets make sure we have all of the variables loaded up for custom pages
    include($phpbb_root_path . 'common.' . $phpEx);
    //Lets put this in there also, it has all of the forums useful functions for displaying certain items
    include($phpbb_root_path . 'includes/functions_display.' . $phpEx); 
 
    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup('my_lang' , 2); //The 2 stands for the style id for this page
 
 
    // Output page
    page_header($user->lang['ABOUT US']);
 
    $template->set_filenames(array(
        'body' => 'about_body.html')
        // ENSURE THAT THE ABOVE FILENAME MATCHES THE FILENAME IN phpBB3/styles/subSilver/template
        // dirrectory! (or subBlack whatever template you are using
    );
 
    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
 
    page_footer();
 
    ?>

There are 3 lines that will need editing to make different pages than about us

page_header($user->lang['ABOUT US']);

pulls the definition from the lang file we are making next

    $template->set_filenames(array(
        'body' => 'about_body.html')

pulls the template up for the browser to display the HTML

The other line closer to the top

    $user->setup('my_lang');

is the name of the language file used by this page named (my_lang.php)

Save this file as about.php

You should see the edits you need to make to change file names.

Next we make the lang file

<?php
    /** 
    *
    * @name my_lang.php  **language file**
    * @version 1.12.07
    * @package -Static Pages my_lang.php
    * @copyright (c) 2008 topdown, validwebs.com
    * @license http://opensource.org/licenses/gpl-license.php GNU Public License 
    *
    */
 
 
    /**
    * DO NOT CHANGE
    */
    if (empty($lang) || !is_array($lang))
    {
        $lang = array();
    }
 
 
    $lang = array_merge($lang, array(
        'ABOUT US'            => 'About Us',
        'CONTACT US'        => 'Contact Us',
        'HOME'                  => 'Home',
 
 
 
            // copyright
        'CUSTOM_COPY'     => '&copy; 2008 topdown, Valid-Webs.com  All rights Reserved.',
 
        ));
 
    ?>

You can see how to add to it

Select All
1
'HOME'                => 'Home',

just copy, paste and rename the HOME to whatever you put in the other files

Then save this file as my_lang.php

Now upload

about_body.html to your styles template directory
about.php to the root, where the forums index.php file is
and the my_lang.php to the language / en directory

Done

Leave a Reply