Topic: Announcements for guests only

Hello all,

I've done some searching but I don't believe this has come up before.  What I'd like to do is place a message atop my forums that's visible only to guests.

I've tried copying the footer.php file, called it welcome.php, and inserted that into the template using <pun_welcome>. That works, it shows two footers, but when I place it above <pun_main> it doesn't show up anymore. I'm probably going to have to change some things in the new welcome.php file but I'm not quite that dexterous yet. Any suggestions?

2 (edited by Tieguy 2009-04-15 20:54)

Re: Announcements for guests only

Put this in header.php right under // END SUBST - <pun_announcement>

// START SUBST - <pun_guest_message>
if ($pun_user['g_id'] == PUN_GUEST)
{
    ob_start();

?>
<div class="block">
    <h2><span>Guest Announcement</span></h2>
    <div class="box">
        <div class="inbox">
            <div>Message here.</div>
        </div>
    </div>
</div>
<?php
    
    $tpl_temp = trim(ob_get_contents());
    $tpl_main = str_replace('<pun_guest_message>', $tpl_temp, $tpl_main);
    ob_end_clean();
}
// END SUBST - <pun_guest_message>

Then, in include/template/main.tpl add:

<pun_guest_message>

Where you want it to show up.

If you need any PunBB 1.2.* mods done, feel free to send me a PM; we can work out a price [if need be].

Re: Announcements for guests only

Why, it works perfectly! Thank you very much, sir!

4 (edited by Ottens 2009-04-16 17:58)

Re: Announcements for guests only

Just a little problem, only in "Opera". For some reason, the guest message in pushing the forums down when people are logged in.

Looks like this:

http://i15.photobucket.com/albums/a371/Childfromthewest/Untitled-2.jpg

How come?

(I've temporarily removed the guest message so that my "Opera" members can see everything all right.)

5

Re: Announcements for guests only

Not guaranteed to be the cause, but try adding a clear to the bottom of that block, like so:

<div class="block">
    <h2><span>Guest Announcement</span></h2>
    <div class="box">
        <div class="inbox">
            <div>Message here.</div>
        </div>
    </div>
</div>
<div class="clearer"></div>

Opera can be a right pain in the arse for layout issues. big_smile

Re: Announcements for guests only

Hmm... doesn't seem to work..

7 (edited by MattF 2009-04-16 18:24)

Re: Announcements for guests only

The link to your site?

Edit: Scrub that. Managed to see it in the screenshot. Enable the guest message again if you could.

Re: Announcements for guests only

http://www.ottens.co.uk/lounge

The stylesheet is at http://www.ottens.co.uk/lounge/style/Gatehouse.css

9

Re: Announcements for guests only

Bugger. Just looked at that code above again. I've got ballbearings for eyes today. big_smile Change the end of that code from:

<?php
    
    $tpl_temp = trim(ob_get_contents());
    $tpl_main = str_replace('<pun_guest_message>', $tpl_temp, $tpl_main);
    ob_end_clean();
}

to:

<?php
    
    $tpl_temp = trim(ob_get_contents());
    $tpl_main = str_replace('<pun_guest_message>', $tpl_temp, $tpl_main);
    ob_end_clean();
}
else
{
    $tpl_main = str_replace('<pun_guest_message>', '', $tpl_main);
}

10

Re: Announcements for guests only

Ah, perfect!  Thank you so much!  big_smile

11

Re: Announcements for guests only

Glad to hear that sorted it. smile

12

Re: Announcements for guests only

Sorry for missing that bit. tongue  Didn't think the absence of the else would effect anything.

If you need any PunBB 1.2.* mods done, feel free to send me a PM; we can work out a price [if need be].

13 (edited by MattF 2009-04-18 08:23)

Re: Announcements for guests only

Tieguy wrote:

Didn't think the absence of the else would effect anything.

To be honest, in general, it doesn't cause too much of a problem. It's just that Opera does tend to punish one for any minor mistakes. big_smile The '<pun_guest_message>' would have been left in the page source when the page was created and a user was logged in. It technically became a start tag with no closing tag.

The reason I have an overly keen eye for these things is that I run all of my code in XHTML1.1 mode, which is served as XML rather than HTML. Hence, anything like that will just prevent the page rendering completely in XML compliant browsers. As you can probably guess, I have to be rather paranoid about making sure every piece of output is perfect. big_smile Even something as minor as a missing double quote will prevent the page from rendering.