Fixing stylesheets for PHPNuke and phpBB

This site used to run PHPNuke with phpBBforums.

I decided to work on my theme.

While trying to work on the forum theme I found that CSSchanges don't work..

Investigating further, I found that the stylesheet for the forums was written as a new <HEAD> inside the <BODY> tags after the default menu bars. The browser just ignored it.

I visited MANY other PHPNuke sites and found the same problem there as well.

Apparently it's the contents of overall_header.tpl that are being placed in the <BODY>.

PHPNuke builds the <HEAD> section, followed by the top menu bar (in theme.php) then calls phpBB.

The forum thinks it's running on a site by itself, so the overall_header.tpl file writes the page including it's own <HEAD> tags. Since PHPNuke has already written the tags and closed them, everything between the new <HEAD> tags is ignored by the browser. They just show up as garbage when you do a View-->Source.

In header.php the stylesheet is called by:

Code:
echo "<LINK REL="StyleSheet" HREF="themes/$ThemeSel/style/style.css" TYPE="text/css">";

In theme.php for any theme, I can put the following in Function themeheader:

Code:
/************************************************************/
/* Function themeheader() */
/* $name added to global */
/************************************************************/

function themeheader() {
global $banners, $sitename, $name;

/************************************************************/
/* replace blocks(left); with */
/************************************************************/

if ($name=='Forums') {
/* Don't display left blocks, any other code if forums active goes here */
}
else {
blocks(left);
}								

This makes the forum go full screen except for the site header/navbar.

The if ($name=='Forums') test works in header.php, so I can use it to write forum head tags when forums are active.

I just removed all code above and including the </HEAD> tag in overall_header.tpl then modified header.php/function head() to contain that code, like this:

Code:
 function head() {

    global $name, $slogan, $sitename, $banners, $nukeurl, $Version_Num, $artpage, $topic, $hlpfile, $user, $hr, $theme, 
           $cookie, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $textcolor1, $textcolor2, $forumpage, $adminpage, $userpage, $pagetitle;
    include("includes/ipban.php");
    $ThemeSel = get_theme();
    include("themes/$ThemeSel/theme.php");
    echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
";
    echo "<html>
";
    echo "<head>
";
    echo "<title>$sitename $pagetitle</title>
";
    include("includes/meta.php");
    include("includes/javascript.php");
    
    if (file_exists("themes/$ThemeSel/images/favicon.ico")) {
	echo "<link REL="shortcut icon" HREF="themes/$ThemeSel/images/favicon.ico" TYPE="image/x-icon">
";
    }
    echo "<link rel="alternate" type="application/rss xml" title="RSS" href="backend.php">
";
    if ($name=='PHP-Nuke_HOWTO') {
    echo "<LINK REL="StyleSheet" HREF="modules/PHP-Nuke_HOWTO/ck-style.css" TYPE="text/css">

"; 
    }
    echo "<LINK REL="StyleSheet" HREF="themes/$ThemeSel/style/style.css" TYPE="text/css">

";

    if ($name=='Forums') { 
    echo "<LINK REL="StyleSheet" HREF="themes/$ThemeSel/forums/forums.css" TYPE="text/css">
";
    echo "<link rel="top" href="modules.php?name=Forums&file=modules&name=Forums&file=modules/Forums/index" title="AnOldMan.com Forum Index" />
";
    echo "<link rel="search" href="modules.php?name=Forums&file=modules&name=Forums&file=modules/Forums/search" title="Search" />
";
    echo "<link rel="help" href="modules.php?name=Forums&file=modules&name=Forums&file=modules/Forums/faq" title="Forum FAQ" />
";
    echo "<link rel="author" href="modules.php?name=Forums&file=modules/Forums/modules&name=Members_List&file=index" title="Memberlist" />
";
    }

    if (file_exists("includes/custom_files/custom_head.php")) {
	  include_once("includes/custom_files/custom_head.php");
    }
    echo "


</head>

";
    if (file_exists("includes/custom_files/custom_header.php")) {
	  include_once("includes/custom_files/custom_header.php");
    }
    themeheader();
    }								

Stylesheets are parsed by browsers based on the last declaration. This sets two stylesheets when forums are active, but only styles that are re-declared are affected. Of course, a lot of the site's styles change when forums are active, but usually the only part of the page truly affected is the menu bar.

The result: no more code showing in the body when you view a page's source, and more importantly: the forum stylesheet now works!

I was amazed at the style changes evident after this, I had never seen the Nuke phpBB in it's native color scheme before!

Files discussed are found on YOUR site here:

PUBLIC_HTML/header.php

PUBLIC_HTML/themes/sometheme/theme.php

PUBLIC_HTML/themes/sometheme/forums/overall_header.tpl

Top