This tutorial has been requested a lot of times since our sister phpBB3 styles website opened this year. phpBB3 already has the built in functionality to become a styles demo - as admins will know, you can preview styles by appending ?style=STYLEID to any forum page. The question is - how can this be extended to members, guests and all other users? The answer is pretty simple and requires a single line of code to be changed.
Find and replace
As I said above, to make a styles demo requires only a single change of the phpBB3 code. The file that needs to be altered is the session.php file inside the includes folder of the phpBB3 root. Open this file and find the following line:
if (!empty($_GET['style']) && $auth->acl_get('a_styles'))
By default this is on line 1469 of the phpBB3.0.2 code. Next step is to replace this line with this PHP code:
if (!empty($_GET['style']))
Save the file and upload it back to your server - all is done! To use the styles demo simply point your browser to your forums index and add ?style=STYLEID to the end of the URL. STYLEID can be got from the Admin panel's Styles page.
Now some may be happy to leave it at that but I know some users may want to know what has been changed and why we change it, if so, read on.
The original line of PHP is a two part if statement which, if true, will load a different style to the board or user default. The first part checks to see if a style ID has been given in the URL. The second part however looks at the users permissions to see if they have admin access to the styles permission. If a user does not (and anyone other than admins will not) then the style won't be applied. The line of code we replace it with only has the first part of the if statement. This means it doesn't matter what the permissions of the user are, the style will always be applied (assuming an ID is given!).
