Bad Boy Blog, an unofficial Diddy and Bad Boy fan blog

Bookmark and Share

Add the phpBB Style Sheet to Any PHP Page (All Databases)

Add the phpBB Style Sheet to Any PHP Page (All Databases)

Postby PdV » April 24th 2006, 9:16 am

I have installed phpBB 2 and couldn't get Closed's solution to work for me.

Whether this was due to an incompatibility with phpBB 2 or simply the setup that I had on my server, I'm not sure, but it led me to having a tinker with the code.

What I found was that Closed's solution was MySQL specific. Now, while I use MySQL as the database, it may not be the same for everyone, so I have amended the solution to work across all databases.

Simply use the following code instead:

Code: Select all
// Start of stylesheet loading 

# Assign necessary stylesheet variables - if user is not logged in use default stylesheet 
if ( !$userdata['session_logged_in'] ) 
$userstyle = $board_config['default_style'];
$userstyle = $userdata['user_style']; 

# Query to execute.
$query = "SELECT * FROM ".THEMES_TABLE." WHERE themes_id = ".$userstyle; 

# Run the query.
$result = $db->sql_query($query);

# Get the first (and only) row.
$row = $db->sql_fetchrow();

# Extract the style and template names.
$template_name = $db->sql_fetchfield('template_name'); 
$style_name = $db->sql_fetchfield('style_name'); 

# Output the style sheet link.
echo '<link rel="stylesheet" href="forum/templates/'.$style_name.'/'.$template_name.'.css" type="text/css"> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'; 

// End of stylesheet checking 

This code assumes that you have installed phpBB in a sub folder called "forum". If you have it elsewhere, then you will need to amend the path after the "href=" tag.
New User
Posts: 1
Joined: April 24th 2006, 8:54 am

Return to phpBB 2: Integrating phpBB With Your Website

Who is online

Users browsing this forum: No registered users and 0 guests