TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 16, 2024, 06:29:05 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,161
  • Total Topics: 21,219
  • Online today: 106
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 82
  • Total: 83
  • @rjen

Greeting Block

Started by rjackson, April 22, 2006, 03:24:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

rjackson

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!';
}

?>

Crip

Cool..
been around awhile, used that years ago. ;)
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes



rjackson

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 :)


G6Cad

That was a rather fun snippet :)

Thanks for sharing your findings  :)

RoarinRow

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

Crip

Quote from: rjackson on April 22, 2006, 03:33:19 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 :)

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

Is there a way to add this to the User info block? Instead of it saying "Hey user" say Good morning User????

sburke930

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?

rebelrose

Quote from: rjackson on April 22, 2006, 03:33:19 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.



Thurnok

Quote from: sburke930 on August 13, 2006, 11: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?

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!