News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Welcome screen question?

Started by ajk, March 03, 2005, 05:49:45 PM

Previous topic - Next topic

ajk

Hi Everyone,

How can I change the Hey, USERNAME, you have a new message!
TO:
Good Morning, Good Afternoon, or Good Evening?

Thanks in advance.

Andy Knifel

Oldiesmann

Sure.... Here's how:

index.template.php

Find
<body>';

Add after that
// First, we calculate the current hour

//Take out any common abbreviation symbols (commas and periods get stripped and hyphens and slashes get replaced with spaces)
str_replace(array('.',',','/','-'), array('','',' ', ' '), $context['current_time']);

//Assume we've got a valid time now (shouldn't be a problem in most cases)
$hour = strftime('%H', strtotime($context['current_time']));

//Now we decide what greeting to use (based on 24-hour time... 13 = 1PM, 14 = 2PM, etc.)

if((int) $hour <= 12)
$greeting = 'Good Morning';
elseif((int) $hour <= 17)
$greeting = 'Good Afternoon';
else
$greeting = 'Good Evening';


Find
echo '
', $txt['hello_member'], ' <b>', $context['user']['name'], '</b>';


Replace
echo '
', $greeting ,' <b>', $context['user']['name'], '</b>';

ajk

Andy Knifel

ajk

One quick question!?

How can I change it to show -5:00 GMT.

The server is -6:00 GMT and the company that wants the BBS and I are on the east coast.
So I'd like it to show with that being the basis.

Here is what I've added so far, in theory.  :-)



// Good morning, afternoon, evening hack -------
// First, we calculate the current hour
//Take out any common abbreviation symbols (commas and periods get stripped and hyphens and slashes get replaced with spaces)
str_replace(array('.',',','/','-'), array('','',' ', ' '), $context['current_time']);
//Assume we've got a valid time now (shouldn't be a problem in most cases)
$hour = strftime('%H', strtotime($context['current_time']));
//Now we decide what greeting to use (based on 24-hour time... 13 = 1PM, 14 = 2PM, etc.)
if((int) $hour <= 11)    [color=Blue]Before 12:00PM[/color]
$greeting = 'Good Morning';
elseif((int) $hour <= 18)  [color=Blue]Before 6:00PM[/color]
$greeting = 'Good Afternoon';
elseif  ((int) $hour <= 24)  [color=Blue]Before 12:00AM[/color]
$greeting = 'Good Evening';


Thanks again!!!!

Andy Knifel

[Unknown]

Try:



// Good morning, afternoon, evening hack -------
// First, we calculate the current hour
//Take out any common abbreviation symbols (commas and periods get stripped and hyphens and slashes get replaced with spaces)
$hour = strftime('%H', forum_time(true));
//Now we decide what greeting to use (based on 24-hour time... 13 = 1PM, 14 = 2PM, etc.)
if((int) $hour <= 11)    //[color=Blue]Before 12:00PM[/color]
$greeting = 'Good Morning';
elseif((int) $hour <= 18)  //[color=Blue]Before 6:00PM[/color]
$greeting = 'Good Afternoon';
elseif  ((int) $hour <= 24)  //[color=Blue]Before 12:00AM[/color]
$greeting = 'Good Evening';


Does that help?

-[Unknown]

Advertisement: