Greeting messages based on time at day

hi, 

 i added block (PHP) saying good morning , good night etc. to users based on the day, it include also the user name if exist and font awesome icon accordingly to the time


date_default_timezone_set('Asia,Jerusalem');

$Hour = date('G');
$memID = $_COOKIE['memberID'];
$nick = getNickName($memID);
if ( $Hour >= 0 && $Hour < 12 ) {
echo "Good Morning ".$nick." <i class='fa fa-sun-o fa-1x' aria-hidden='true'></i>";
} else if ( $Hour >= 12 && $Hour < 17 ) {
echo "Good Aftrenoon ".$nick." <i class='fa fa-cutlery fa-1x' aria-hidden='true'></i>";
} else if ( $Hour >= 17 && $Hour < 24 ) {
echo "Good Evening ".$nick." <i class='fa fa-moon-o fa-1x' aria-hidden='true'></i>
";
}


Always remember that the future comes one day at a time.
Quote · 18 Sep 2017

Nice. Does it know what timezone people are in?

Typo.... Good Afternoon.

~~~~~~~~~~~~~~~~~~~~~~
Michel - Meta-Travel.com
~~~~~~~~~~~~~~~~~~~~~~

TravelNotes.org - The Online Guide to Travel
Quote · 18 Sep 2017

you need to change it here date_default_timezone_set('Asia,Jerusalem');

Always remember that the future comes one day at a time.
Quote · 19 Sep 2017

It has been tested and confirmed working on 7.3.5

Quote · 8 May 2018

It works fine. Just change the timezone to your country and add the code to a PHP block.

I've PM'd you.

Quote · 9 May 2018

I'm not sure why it's not showing my replys lol I seem to be having an issue getting the font awesome to show. Any ideas on why?

Quote · 9 May 2018

Avoid using non web-safe fonts unless you know what you're doing. Always get things working without the bells and whistles and add them later. Do a search here for google fonts because there's been some discussion about getting them to work.

Quote · 9 May 2018

How would I use the users real name instead of their username?

Quote · 13 May 2018

It's a matter of taste. I find both of these offensive:

Good Morning CatFace99001166.

Good Morning Richard Tracy

I've used the First name field and changed it to read: Preferred Name. That way the member can add KittyCat (no offence) or Dick.

Thus the message would read: Good Morning KittyCat, or Good Morning Dick.

Hopefully a simple change from:

$nick = getNickName($memID);

to

$nick = getFirstName($memID);

should do it, or use

$nick =getFullName($memID);

(All untested)

 

 

 
Quote · 13 May 2018

Lol you said no offense to kittycat. That's funny :) glad to see you have a sense of humor lol

Quote · 13 May 2018

Ok so let's say I make a new "Name" field and say $nick =getName($memID); ?

Quote · 13 May 2018

ok so i just got home and i tried to change it to the values that you said, it throws a error 500 to the site. so that didnt work. any other suggestions?

Quote · 13 May 2018

I had a quick look at it. With my very limited knowledge and never having used "Get" before, I'm thinking NickName is indexed and other fields are not. I'm sorry but I don't have much time to take it any further at this stage, but it's on my to do list.

Quote · 13 May 2018

I've been trying too lmao I think I have to add something to the db. I'm still learning how dolphin blocks work. As soon as I figure it out it'll be easy as I know PHP hahah

Quote · 14 May 2018

to change the nickname from the "username" to the "full name" you would change that in the admin panel -> settings -> advanced settings -> Profiles part. 

Quote · 15 May 2018

Nope! Username is important.

This works. (See attachment)

Many thanks to Deano again. We miss him!

I'll work on the icons when I get time.

Welcome Message.rtf · 1.7K · 356 downloads
Quote · 15 May 2018

Have you given a look at what i wrote John?

I have tested this already and that code isnt needed. take a look at the included screenshots

 

With this first one you can see me changing the display name in the admin panel.

https://gyazo.com/d7679055462e5ab0eb19baf7fc95fdb7

 

In this next one you will see the Full Name being shown.

https://gyazo.com/837365b0dd3f7bde2e5335a8b27b0d2d

 

And in this one you can see the username being shown

https://gyazo.com/c2c06dea57a0e83fbe7b3c9d88fe912c

 

Now this is all by using the default code from the original post. there is no need to change the code as you have shown. (maybe they just added this feature and you havent updated it yet? idk but this is what is working for me.)

 

AlexT even states here

https://gyazo.com/086522155e12f9da507f540655fcdf31 

 

Thanks

The Purple Puppy

Quote · 15 May 2018

Sorry, but I read it before my morning coffee. I actually do that on all my sites, but I've been testing on a clean 7.3.5 install and I forgot to do it. I'm running Modzzz version of this on my main site so I was unable to test it there. 

Yep, that must do it as you've proven, but maybe you can still use my code if you want to use First Name, which I've called "Preferred Name" in Profile Edit . As I said before, some people may prefer to see Good Morning Dick, rather than Good Morning Richard Tracy. 

Geez That shoes my age doesn't it?

Quote · 16 May 2018

where should the PHP block be written? in which file?

Quote · 19 Jan 2019

Hello 

The PHP block is some code written for the record from `sys_page_compose` table. You may write it directly in this table, for the `Content` field (in this case the value of `Func` field should be 'PHP'). The good example of this case is the result of the following query:

 

SELECT * FROM `sys_page_compose` WHERE `Page`='index' AND `Desc`='Public Photos' LIMIT 1;


Another case is in the writing of PHP block code in Page class. In this case, the item's record for `sys_page_compose` table has the `Func` field's value as the last word from the getBlockCode_[Func] method.

 

See the example from the file modules/boonex/photos/classes/BxPhotosPageHome.php (method getBlockCode_LatestFile) and the result of the following MySQL query:

 

SELECT * FROM `sys_page_compose` WHERE `Page`='bx_photos_home' AND `Func`='LatestFile' LIMIT 1;

Quote · 19 Jan 2019
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.