simple style demo for phpbb2

Simple style demo for phpBB2

Submitted by DoubleJ, Mar 2007.
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

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:
  1. function setup_style($style)
     
  2. {
     
  3.    global $db, $board_config, $template, $images, $phpbb_root_path; 
Replace with:
Code:
  1. function setup_style($style)
     
  2. {
     
  3.    global $db, $board_config, $template, $images, $phpbb_root_path, $HTTP_GET_VARS;
     
  4.    //
     
  5.    // Check if a style ID is added to the url, and make sure it is not emtpy.
     
  6.    //
     
  7.    if( isset($HTTP_GET_VARS[‘st’]) && !empty($HTTP_GET_VARS[‘st’]) && is_numeric($HTTP_GET_VARS[‘st’]) )
     
  8.    {
     
  9.        $style = intval($HTTP_GET_VARS[‘st’]);
     
  10.    } 

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.

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:
  1. function append_sid($url, $non_html_amp = false)
     
  2. {
     
  3.    global $SID; 
Replace with:
Code:
  1. function append_sid($url, $non_html_amp = false)
     
  2. {
     
  3.    global $SID, $HTTP_GET_VARS; 
Find:
Code:
  1.    if ( !empty($SID) && !preg_match(‘#sid=#’, $url) )
     
  2.    {
     
  3.        $url .= ( ( strpos($url, ‘?’) !== false ) ?  ( ( $non_html_amp ) ? ‘&’ : ‘&’ ) : ‘?’ ) . $SID;
     
  4.    } 
After add:
Code:
  1.    if ( !preg_match(‘#st=#’, $url) )
     
  2.    {
     
  3.        $url .= ( ( strpos($url, ‘?’) !== false ) ?  ( ( $non_html_amp ) ? ‘&’ : ‘&’ ) : ‘?’ ) . ‘st=’ . $HTTP_GET_VARS[‘st’];
     
  4.    } 
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.

Share this tutorial

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

HTML Link:
Simple style demo for 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.