Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Phoenix Man on February 15, 2006, 02:54:00 PM

Title: Guest Message
Post by: Phoenix Man on February 15, 2006, 02:54:00 PM
Hi. I was wondering if anyone could write a small tutorial on how to add a Guest message.

In "Settings.php" there would be a variable called $guestmsg which would default to 0.
What I want to do is on every page on the forum whenever a Guest is logged in and $guestmsg is not 0 (but instead a string) I want to display the string as a Guest message just like when you get those warning messages like "You cannot post private messages".

I wish to use this to inform my dear Guests that some forums are not visible to them unless they register (to encourage registering).
Title: Re: Guest Message
Post by: H on February 15, 2006, 04:13:27 PM
Do the is_guest info in this topic help:

http://www.simplemachines.org/community/index.php?topic=60003.0
Title: Re: Guest Message
Post by: Phoenix Man on February 15, 2006, 04:23:21 PM
Alright I don't understand. That link refers to an old bug post...?
Title: Re: Guest Message
Post by: fwitt on February 15, 2006, 05:11:50 PM
you'll want something along the lines of

at the top of each template you used it in



global guestmsg;



then everywhere that you wanted the msg to display



if ($context['user']['is_guest'] && ($guestmsg != 0))
{
echo " $guestmsg ";
}



Title: Re: Guest Message
Post by: Phoenix Man on February 15, 2006, 05:34:16 PM
Ok. Where can I put it to appear on EVERY page?
Title: Re: Guest Message
Post by: kegobeer on February 15, 2006, 06:13:09 PM
Boards are hidden unless a visitor has access to it.  If I deny guest access to a particular board, guests can't see anything about that board.  Were you planning on putting some sort of message on the top of every page telling your guests that you have other boards they can't see?
Title: Re: Guest Message
Post by: fwitt on February 16, 2006, 03:30:24 AM
Quote from: Phoenix Man on February 15, 2006, 05:34:16 PM
Ok. Where can I put it to appear on EVERY page?

Do you want it to appear in the same way as the news block?
Title: Re: Guest Message
Post by: Phoenix Man on February 16, 2006, 02:44:52 PM
Quote from: kegobeer on February 15, 2006, 06:13:09 PM
Boards are hidden unless a visitor has access to it.  If I deny guest access to a particular board, guests can't see anything about that board.  Were you planning on putting some sort of message on the top of every page telling your guests that you have other boards they can't see?
Yes. I want to inform them that they have to register to see the other boards. Maybe even show a list of boards they don't have access to.

Yes.
Quote from: fwitt on February 16, 2006, 03:30:24 AMDo you want it to appear in the same way as the news block?
I'd like to make it appear like if you were banned.

Like this, but then with $guestmsg and only for Guests:
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg105.imageshack.us%2Fimg105%2F8215%2Flikethis9nd.png&hash=22d36480eb84c4502f948ca7c31ca50db9602529)
Title: Re: Guest Message
Post by: kegobeer on February 16, 2006, 04:03:30 PM
You would put that type of code in index.template.php.  That would guarantee every page would have your message on it.