Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

August 19, 2022, 04:34:23 AM

Login with username, password and session length
Members
  • Total Members: 3843
  • Latest: Tricky
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 51
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 1
Guests: 40
Total: 41

Author Topic: Greeting Block  (Read 20486 times)

0 Members and 1 Guest are viewing this topic.

rjackson

  • Guest
Greeting Block
« on: April 22, 2006, 08:24:48 AM »
I found this little bloc on a site, you can set a greeting message to display based on the time of day it is.

--------------------------------------------------------
<?php

$hour = date('G');

if($hour >= 0 && $hour <= 7)
{
        echo 'Very early, isnt it?';
}
else if($hour <= 8 && $hour <= 12)
{
        echo 'Good morning!';
}
else if($hour >= 13 && $hour <= 16)
{
        echo 'Good afternoon!';
}
else if($hour >= 17 && $hour <= 23)
{
        echo 'Good evening!';
}

?>

Offline Crip

  • Jesus Inside.
  • Themes
  • *
  • Posts: 4168
  • Theme Support
    • Cripzone
Re: Greeting Block
« Reply #1 on: April 22, 2006, 08:30:54 AM »
Cool..
been around awhile, used that years ago. ;)
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes


rjackson

  • Guest
Re: Greeting Block
« Reply #2 on: April 22, 2006, 08:33:19 AM »
found it kinda neat, and since I know nothing of coding, figure I stick whatever I find up for others...if its something old. I'm sorry its new to me :)


Offline G6Cad

  • Friends
  • *
  • Posts: 12643
    • FamiljeGodis
Re: Greeting Block
« Reply #3 on: April 22, 2006, 08:47:31 AM »
That was a rather fun snippet :)

Thanks for sharing your findings  :)

Offline RoarinRow

  • Hero Member
  • *****
  • Posts: 1034
  • Ride my AV!
    • Avalanche Style
Re: Greeting Block
« Reply #4 on: April 22, 2006, 09:14:04 AM »
Thanks for sharing.  I appreciate any kind of snippet since I'm not a coder by any means.   :uglystupid2: 

SMF 2.0 RC3
TP 1.0 beta 5-1
Wordpress 3.0

Offline Crip

  • Jesus Inside.
  • Themes
  • *
  • Posts: 4168
  • Theme Support
    • Cripzone
Re: Greeting Block
« Reply #5 on: April 22, 2006, 09:58:25 AM »
found it kinda neat, and since I know nothing of coding, figure I stick whatever I find up for others...if its something old. I'm sorry its new to me :)

It is an old one, but I stil see it being used all over the net,  so thanks for sharing the snippet. :)
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes


HaxXxoR

  • Guest
Re: Greeting Block
« Reply #6 on: April 22, 2006, 11:03:38 AM »
Is there a way to add this to the User info block? Instead of it saying "Hey user" say Good morning User????

sburke930

  • Guest
Re: Greeting Block
« Reply #7 on: August 13, 2006, 04:05:09 PM »
I put this code into a block and added the {$MemberName} code but I cannot get it to work.  I've made sure it was a php block, I've not deleted anything but I cannot for the life of me understand why it will not work.  Does someone have a quick answer they could give me?

Offline rebelrose

  • Friends
  • *
  • Posts: 945
Re: Greeting Block
« Reply #8 on: August 13, 2006, 10:43:46 PM »
found it kinda neat, and since I know nothing of coding, figure I stick whatever I find up for others...if its something old. I'm sorry its new to me :)

Thanks, all the code anyone can give me is great, as I know little of code myself. New or old.



Offline Thurnok

  • Friends
  • *
  • Posts: 784
Re: Greeting Block
« Reply #9 on: August 14, 2006, 12:19:31 AM »
I put this code into a block and added the {$MemberName} code but I cannot get it to work.  I've made sure it was a php block, I've not deleted anything but I cannot for the life of me understand why it will not work.  Does someone have a quick answer they could give me?

First you need to define the variable you need access to as a global, then you can use it.  To do what you want, add this to the top of your snippet block:
global $user_info;

Then, you can add to the greetings at the end of the echo statement like thus:
 echo 'Good evening ' . $user_info['username'] . '!';
That would produce the output with the user's username like:
Good evening Thurnok!