Community management insight at ManagingCommunities.com

Bookmark and Share

Add the phpBB Style Sheet to Any PHP Page

Add the phpBB Style Sheet to Any PHP Page

Postby Closed » November 23rd 2003, 9:05 am

Instead of just using the regular subSilver style sheet on pages, with the script below it is possible to load the style sheet used in the logged in user's chosen style.

You will need to put the following bits of code in your PHP page. If you do not have programming knowledge, this might not make much sense.

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 = 1;
}
else
{
$userstyle = $userdata['user_style'];
}

# Assign variable to the query so that it canbe checked by hte custom error handler
$query = "SELECT `template_name`, `style_name` FROM `phpbb_themes` WHERE `themes_id` = $userstyle";
	@mysql_query($query, $connection)
			or die("error with query: " . mysql_error() . "\n\nQuery: " . $query);
			$result = mysql_query($query);
while( $row = mysql_fetch_array($result) )   
		{
		$template_name = $row['template_name'];
		$style_name = $row['style_name'];
		}
			
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
//


Note: You will also need the below code at the top of your page:

Code: Select all
# phpBB stuff
define('IN_PHPBB', true);
$phpbb_root_path = 'CHANGE ME';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//


The only line that needs to be changed is the third. Simple change the text to you forum location. Example: /forum/

Note: If you are running a Linux server you may use ../ to signal to look up one level.
Closed
New User
 
Posts: 11
Joined: December 21st 2002, 12:04 pm

Return to phpBB 2: Integrating phpBB With Your Website

Who is online

Users browsing this forum: No registered users and 0 guests