Home

Forums

Statistics

Surveys

Top Ten

Your Account


Login
Nickname

Password

Security Code: Security Code
Type Security Code

Don't have an account yet? You can create one. As a registered user you have some advantages like a private journal and posting comments or additions to articles.

Who's Online
There are currently, 9 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here

Donations
If you find the information here useful,
help keep this web site online with a donation!
YTD Donations
$1.00
Thank You!

Host referer


  
Fixing stylesheets for PHPNuke and phpBB
Posted on Wednesday, March 08 @ 23:07:55 CST
Topic: 5: Strange things I have been up to
This site runs PHPNuke with phpBB forums.

I decided to work on my theme.

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

Investigating further, I found that the stylesheet for the forums was written in the html in the <BODY> after the default menu bars. The browser just ignores 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 forums here work in this manner.

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 remove all code above and including the </HEAD> tag in overall_header.tpl then modify 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\">\n";
    echo "<html>\n";
    echo "<head>\n";
    echo "<title>$sitename $pagetitle</title>\n";
    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\">\n";
    }
    echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"backend.php\">\n";
    if ($name=='PHP-Nuke_HOWTO') {
    echo "<LINK REL=\"StyleSheet\" HREF=\"modules/PHP-Nuke_HOWTO/ck-style.css\" TYPE=\"text/css\">\n\n"; 
    }
    echo "<LINK REL=\"StyleSheet\" HREF=\"themes/$ThemeSel/style/style.css\" TYPE=\"text/css\">\n\n";

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

    if (file_exists("includes/custom_files/custom_head.php")) {
	  include_once("includes/custom_files/custom_head.php");
    }
    echo "\n\n\n</head>\n\n";
    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. I am setting two stylesheets when forums are active, but only styles that are re-declared are affected. Of course, a lot of the site's style changes when forums are active, but since I have blocks(left); disabled then, the only part of the page truly affected is the menu bar. I have it's layout/style hardcoded in theme.php, so it makes no difference.

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 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



Remember: Questions can be posted in the FORUM section !

whew! getting this page to parse properly with html and php code in it was a nightmare!


 
Related Links
· More about 5: Strange things I have been up to
· News by anoldman


Most read story about 5: Strange things I have been up to:
Re-wiring a three phase generator


Article Rating
Average Score: 0
Votes: 0

Please take a second and vote for this article:

Excellent
Very Good
Good
Regular
Bad


Options

 Printer Friendly Printer Friendly

 Send to a Friend Send to a Friend


Please take a second and vote for this article.
Web site powered by PHP-Nuke

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © 2003 by AnOldMan.com
PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.07 Seconds