Simple style demo for phpBB2
This tutorial will explain to you, how you can easily create demo system so you can show off your phpBB2 styles.
Files we will edit for this are:
includes/functions.php
includes/sessions.php
It gets the style ID when the user preferences are loaded.
What we simply do here is ignore the style_id that has been entered but we will first check if the url contains the style ID. If it doesn't then simply load the style it would normally load.
Open functions.php
Find:
Files we will edit for this are:
includes/functions.php
includes/sessions.php
1. Validating url's style_id
First off, in functions.php is a function called "setup_style()" which is responsible for loading the desired template.It gets the style ID when the user preferences are loaded.
What we simply do here is ignore the style_id that has been entered but we will first check if the url contains the style ID. If it doesn't then simply load the style it would normally load.
Open functions.php
Find:
Code:
- function setup_style($style)
- {
- global $db, $board_config, $template, $images, $phpbb_root_path;
Replace with:
Code:
- function setup_style($style)
- {
- global $db, $board_config, $template, $images, $phpbb_root_path, $HTTP_GET_VARS;
- //
- // Check if a style ID is added to the url, and make sure it is not emtpy.
- //
- if( isset($HTTP_GET_VARS['st']) && !empty($HTTP_GET_VARS['st']) && is_numeric($HTTP_GET_VARS['st']) )
- {
- $style = intval($HTTP_GET_VARS['st']);
- }
Now if we have added a style_id to the url( index.php?st=1 ) we see that style. But normal links on the board do not contain the style_id in the url.
open sessions.php
Find:
2. Add style_id to all urls
To fix that we will modify the "append_sid()" function which is called with every url and adds a session ID. it will now add the style ID for us.open sessions.php
Find:
Code:
- function append_sid($url, $non_html_amp = false)
- {
- global $SID;
Replace with:
Code:
- function append_sid($url, $non_html_amp = false)
- {
- global $SID, $HTTP_GET_VARS;
Find:
Code:
- if ( !empty($SID) && !preg_match('#sid=#', $url) )
- {
- $url .= ( ( strpos($url, '?') !== false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
- }
After add:
Code:
- if ( !preg_match('#st=#', $url) )
- {
- $url .= ( ( strpos($url, '?') !== false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . 'st=' . $HTTP_GET_VARS['st'];
- }
Now the style ID is added to every url on the forum.
And your done with your basic style demo. You can apply this to your main forum, so guests can see additional styles, or apply to a seperate forum.
And your done with your basic style demo. You can apply this to your main forum, so guests can see additional styles, or apply to a seperate forum.