[phpBB 2.0 How to] Create simple style demo board.

Tutorials for creation, installation and management of phpBB styles.

Moderator: Moderators

[phpBB 2.0 How to] Create simple style demo board.

Postby DoubleJ on Sun Apr 23, 2006 8:34 pm

In this tutorial I will explain how you can easily create a simple style demo yourselve.

Files we will edit for this are:
includes/functions.php
includes/sessions.php

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: Select all
function setup_style($style)
{
   global $db, $board_config, $template, $images, $phpbb_root_path;


Replace with:
Code: Select all
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']) && intval($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.

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: Select all
function append_sid($url, $non_html_amp = false)
{
   global $SID;

Replace with:
Code: Select all
function append_sid($url, $non_html_amp = false)
{
   global $SID, $HTTP_GET_VARS;

Find:
Code: Select all
   if ( !empty($SID) && !preg_match('#sid=#', $url) )
   {
      $url .= ( ( strpos($url, '?') !== false ) ?  ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
   }

After add:
Code: Select all
   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.
It never hurts to help.....
[ My phpBB Mods and Styles ]
My Mod: [ Simple Shoutbox Mod ]
[ DoubleJWeb ] [ Get Opera ]
User avatar
DoubleJ
Moderator
Moderator
 
Posts: 716
Joined: Sat Jan 22, 2005 9:58 pm
Location: DoubleJWeb.Net

Postby Reiji Kurosaky on Sun Apr 23, 2006 9:54 pm

Hello,

This will be useful, thanks.
My sites:
Villavizar.com

My Styles:
[Venus]
User avatar
Reiji Kurosaky
Registered User
Registered User
 
Posts: 858
Joined: Sat Dec 03, 2005 4:05 pm

Postby Reiji Kurosaky on Sun Apr 23, 2006 10:22 pm

Uh, I have a problem.

After applying this, all the link lead to index.php (Profile, Search, etc.)

What´s causing this?
My sites:
Villavizar.com

My Styles:
[Venus]
User avatar
Reiji Kurosaky
Registered User
Registered User
 
Posts: 858
Joined: Sat Dec 03, 2005 4:05 pm

Postby DoubleJ on Mon Apr 24, 2006 8:28 am

These code changes shouldn't effect the content of the links.
it would just add the st=# behind the url if it wasn't included yet.
It never hurts to help.....
[ My phpBB Mods and Styles ]
My Mod: [ Simple Shoutbox Mod ]
[ DoubleJWeb ] [ Get Opera ]
User avatar
DoubleJ
Moderator
Moderator
 
Posts: 716
Joined: Sat Jan 22, 2005 9:58 pm
Location: DoubleJWeb.Net

Postby Reiji Kurosaky on Mon Apr 24, 2006 9:33 am

Well, it was this (because I don´t use any other MOD on my demo board) and after I removed the code from those files, everything was back to normal.
My sites:
Villavizar.com

My Styles:
[Venus]
User avatar
Reiji Kurosaky
Registered User
Registered User
 
Posts: 858
Joined: Sat Dec 03, 2005 4:05 pm

Postby DoubleJ on Mon Apr 24, 2006 1:23 pm

[quote user="Reiji Kurosaky" post="74346"]Well, it was this (because I don´t use any other MOD on my demo board) and after I removed the code from those files, everything was back to normal.[/quote]
I have tried this code on a fresh phpBB install with no mods or whatsoever, and it just works.
Make sure you applied all changes correctly.
It never hurts to help.....
[ My phpBB Mods and Styles ]
My Mod: [ Simple Shoutbox Mod ]
[ DoubleJWeb ] [ Get Opera ]
User avatar
DoubleJ
Moderator
Moderator
 
Posts: 716
Joined: Sat Jan 22, 2005 9:58 pm
Location: DoubleJWeb.Net

Postby Reiji Kurosaky on Sat May 13, 2006 6:03 pm

Okay, now it works.

Thank you again DoubleJ.
My sites:
Villavizar.com

My Styles:
[Venus]
User avatar
Reiji Kurosaky
Registered User
Registered User
 
Posts: 858
Joined: Sat Dec 03, 2005 4:05 pm

Postby pinocchio on Fri Jan 05, 2007 9:41 pm

`Thanks for the tutorial

At this case guest can change there style (only de first two A`s)
http://www.pinocchio.nl/phpbb/ (testforum)

But i can`t login as administrator anymore.
I see the also the forum in the leftframe or
it`s redirect to the frontpage after login for the second time.



I realy need this solution for guest
with a visual disease but will be stay anonymouse.

How can i fix this in the sessions.php?
(Javascript is no option for me)


Thanks.
pinocchio
Registered User
Registered User
 
Posts: 2
Joined: Fri Jan 05, 2007 9:31 pm

Postby pinocchio on Sat Jan 06, 2007 6:20 am

pinocchio
Registered User
Registered User
 
Posts: 2
Joined: Fri Jan 05, 2007 9:31 pm

Postby GHS on Sat Jan 06, 2007 6:35 am

Simple but very efficient tutorial, congratulations. :wink:
Porting ExtremeDark Red to phpBB 3 :]
User avatar
GHS
Designer
Designer
 
Posts: 109
Joined: Sun Oct 01, 2006 3:21 pm
Location: Rio Grande do Sul - BR

Postby odessit on Tue Apr 10, 2007 3:48 pm

Thank you for an outstanding tutorial. This does 90% of what I am looking for. Is there a way to also pass style ID with the account activation link and possibly store in a cookie as well?

I am running two different sites (same subject) with different designs. i would love to be able to share a forum between them while preserving the look and feel of the site the user came from.
odessit
Registered User
Registered User
 
Posts: 1
Joined: Tue Apr 10, 2007 3:23 pm


Return to phpBB Styles Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest