Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Phoenix Man - helmikuu 15, 2006, 02:54:00 IP

Otsikko: Guest Message
Kirjoitti: Phoenix Man - helmikuu 15, 2006, 02:54:00 IP
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).
Otsikko: Re: Guest Message
Kirjoitti: H - helmikuu 15, 2006, 04:13:27 IP
Do the is_guest info in this topic help:

http://www.simplemachines.org/community/index.php?topic=60003.0
Otsikko: Re: Guest Message
Kirjoitti: Phoenix Man - helmikuu 15, 2006, 04:23:21 IP
Alright I don't understand. That link refers to an old bug post...?
Otsikko: Re: Guest Message
Kirjoitti: fwitt - helmikuu 15, 2006, 05:11:50 IP
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 ";
}



Otsikko: Re: Guest Message
Kirjoitti: Phoenix Man - helmikuu 15, 2006, 05:34:16 IP
Ok. Where can I put it to appear on EVERY page?
Otsikko: Re: Guest Message
Kirjoitti: kegobeer - helmikuu 15, 2006, 06:13:09 IP
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?
Otsikko: Re: Guest Message
Kirjoitti: fwitt - helmikuu 16, 2006, 03:30:24 AP
Lainaus käyttäjältä: Phoenix Man - helmikuu 15, 2006, 05:34:16 IP
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?
Otsikko: Re: Guest Message
Kirjoitti: Phoenix Man - helmikuu 16, 2006, 02:44:52 IP
Lainaus käyttäjältä: kegobeer - helmikuu 15, 2006, 06:13:09 IP
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.
Lainaus käyttäjältä: fwitt - helmikuu 16, 2006, 03:30:24 APDo 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:
Otsikko: Re: Guest Message
Kirjoitti: kegobeer - helmikuu 16, 2006, 04:03:30 IP
You would put that type of code in index.template.php.  That would guarantee every page would have your message on it.