1

Topic: Masthead shows up above DOCTYPE declaration

Hello,
I'm trying to integrate PunBB into my site in such a way that my site-wide navigation/masthead appears at the top of all my PunBB pages, but I'm having a problem getting it to show up in the right place.  Instead of appearing where I want it to, between <body> and <div id="punwrap">, the masthead is appearing at the top of the document, before the DOCTYPE declaration.


Instead of inserting it to where I want it, it leaves this empty (my masthead is supposed to show up between the below tags):

<body id="punbb">



<div id="punwrap">

And throws the masthead above the doctype declaration:

        <div id="masthead">
        <div id="logo"><img src="/site/public/images/logo.gif" /></div>
        <ul id="nav">
             <li id="t-contact" class="last"><a href="/site/contact">Contact</a></li>
            <li id="t-forum"><a href="/site/forum">Forum</a></li>
            <li id="t-blog"><a href="/site/blog">Blog</a></li>
            <li id="t-home"><a href="/site/">Home</a></li>
        </ul>
        </div>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html dir="ltr">

I added <site_nav> in the header.php file:

// END SUBST - <body>

//START SUBST <site_nav>, calls display_nav from segments.inc
$navigation = display_nav();
$tpl_nav = $navigation;

$tpl_main = str_replace('<site_nav>', $tpl_nav, $tpl_main);
// END SUBST - <site_nav>

// START SUBST - <pun_page>

And inserted it where I wanted it in the 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>
<link rel="stylesheet" href="http://localhost/elginite/site_style.css" type="text/css" media="screen" />
</head>
<body id="punbb">

<site_nav>

<div id="punwrap">

I'm not that experienced with PHP, so I might be doing something obviously wrong.  I don't know, but I've run out of ideas, and I would really appreciate any help I can get on this!  Thank you for replying.

~Rick

Re: Masthead shows up above DOCTYPE declaration

Is display_nav echoing the results instead of storing them as a string?

3

Re: Masthead shows up above DOCTYPE declaration

My Smartys,
Thanks for helping out.  I don't know PHP that well so I'm actually not sure how to answer your question about whether it's echoing directly or being stored to a string.  So I'll let the code speak for itself smile

This is what my display_nav() function looks like:

    function display_nav() {
    ?>
        <div id="masthead">
        <div id="logo"><img src="/site/public/images/logo.gif" /></div>
        <ul id="nav">
             <li id="t-contact"><a href="/site/contact">Contact</a></li>
            <li id="t-forum"><a href="/site/forum">Forum</a></li>
            <li id="t-blog"><a href="/site/blog">Blog</a></li>
            <li id="t-home"><a href="/site/">Home</a></li>
        </ul>
        </div>
    <?php 
    } // end of display_head function

Re: Masthead shows up above DOCTYPE declaration

Yeah, that's the issue: the function isn't returning a string, it's just outputting HTML (not storing it anywhere)
replace your function with this:

    function display_nav() {
        return '<div id="masthead">
        <div id="logo"><img src="/site/public/images/logo.gif" /></div>
        <ul id="nav">
             <li id="t-contact"><a href="/site/contact">Contact</a></li>
            <li id="t-forum"><a href="/site/forum">Forum</a></li>
            <li id="t-blog"><a href="/site/blog">Blog</a></li>
            <li id="t-home"><a href="/site/">Home</a></li>
        </ul>
        </div>';
    } // end of display_head function

5

Re: Masthead shows up above DOCTYPE declaration

Hi Smartys,
Thanks for your suggestion.  It worked perfectly for PunBB, and now the masthead is inserted in the right place. 

However, now the masthead disappears from the rest of the site!  Do you have any suggestions on how I might fix this?

Apparently the rest of my site needs those two php tags:
    ?>
    <?php

inside the body of the display_nav() method. Or they don't like it being saved to a string? This is how I call display_nav() in other parts of the site:

<body id="wordpress">
<?php display_nav(); ?>
<div id="page">

I'd really appreciate any further help you can give. Thanks!

-Rick

Re: Masthead shows up above DOCTYPE declaration

Yeah, you can't have it both ways without a change in the way you call it elsewhere tongue

<body id="wordpress">
<?php echo display_nav(); ?>
<div id="page">

7

Re: Masthead shows up above DOCTYPE declaration

Smartys wrote:

Yeah, you can't have it both ways without a change in the way you call it elsewhere tongue

Darn! I guess I'll just use two different methods, one for PunBB and one for the rest of the site.

Thank you, Smartys!

Rick

Re: Masthead shows up above DOCTYPE declaration

Why not just change the other calls to echos? Are there that many? wink