Topic: Need help integrating a header for different parts of a forum

So I have a site where I'd like to use a punbb forum instead of vbulletin (cause it's just so much faster and easier to use) but I'm running into a problem adjusting punbb to match my sites look and feel.

Basically I have different headers for different parts of the forum. Now I was thinking I could make this work in punbb by doing this:

ex. 

<?php
    if($_GET['id']==3){ 
    echo"output our header";
    echo "<div style=\"background-color:#cdcdcd;width:100%\">beautiful</div>";
    }
    else{}
?>

I have included the following code inside of banner.php which is included in the main.tpl file using the punbb include method. The problem is that when I click a post, the banner disappears even though I'm still inside that forum. This is because the id is no longer equal to 3 because it is based off a URL like so:

/viewtopic.php?id=2

Instead of...
/viewforum.php?id=3

So how can you maintain a header inside of a forum, and inside of the posts within that forum?

Thanks!

Re: Need help integrating a header for different parts of a forum

in header.php (for 1.2.12 atleast) the pun tags from the templates are replaced with whatever they represent.  you can add replacement functionality just like that for your own things. 

// Load the template
if (defined('PUN_ADMIN_CONSOLE'))
    $tpl_main = file_get_contents(PUN_ROOT.'include/template/admin.tpl');
else if (defined('PUN_HELP'))
    $tpl_main = file_get_contents(PUN_ROOT.'include/template/help.tpl');
else
    $tpl_main = file_get_contents(PUN_ROOT.'include/template/main.tpl');


// START SUBST - <pun_content_direction>
$tpl_main = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_main);
// END SUBST - <pun_content_direction>

add something like the last 3 lines to your header.php where you replace the '<your_tag>' with your custom stuff based on PHP_SELF and whatever other query string parameters you need.

Re: Need help integrating a header for different parts of a forum

Could you explain this a little more for me... I'm not sure I follow your idea here.

4 (edited by MadHatter 2006-07-05 19:20)

Re: Need help integrating a header for different parts of a forum

add some custom tag to your main.tpl file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html dir="<pun_content_direction>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<pun_char_encoding>" />
<pun_head>
<your_content>
</head>

then in header.php (right after the parts I previously posted)

// START SUBST - <your_content>
// determine the page context here
if (eregi("viewtopic.php", $PHP_SELF)) {
    // if you need to find the id do so here
    if($_GET['id'] && $_GET['id] == 3) {

        // if you want to have--for instance--different styles for each topic, you can define 
        // custom style sheets for each, and place the link to that in your lang files
        $tpl_main = str_replace('<your_content>', $lang_common['viewtopic_custom_header'], $tpl_main);
    }
}else if(eregi("viewforum.php", $PHP_SELF)) {
    // change your custom header based on a viewforum page
}else if(eregi("profile.php", $PHP_SELF)) {
    // change your custom header based on a profile being displayed
}
// END SUBST - <your_content>

for the $lang_common['viewtopic_custom_header'] bit to work you need to do the following:
in lang/YOUR_LANG/common.php
go to the last line, make sure there's a comma after the last quote mark:

'Posted' => 'Posted', // The date/time a topic was started

and after that line add:

'viewtopic_custom_header' => 'your custom html headers here'