Sinisterly
Gold Adding a Dynamic Welcome Message - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Design (https://sinister.ly/Forum-Design)
+--- Forum: Web Design (https://sinister.ly/Forum-Web-Design)
+--- Thread: Gold Adding a Dynamic Welcome Message (/Thread-Gold-Adding-a-Dynamic-Welcome-Message)



Adding a Dynamic Welcome Message - Cyan - 12-23-2013

Ok today I will be showing you how to Make a dynamic welcome message

Open Your Templates and go to your header templates then Member Template after you want to add this code to the top
Code:
<script type="text/javascript"><!-- var d = new Date(); var n = d.getHours(); if (n < 4) { document.write("<b>Still awake? </b>"); } else if (n < 10) { document.write("<b>Good Morning!</b>"); } else if (n < 16) { document.write("<b>Good Day!</b>"); } else if (n < 20) { document.write("<b>Good Evening!</b>"); } else { document.write("<b>Night time!</b>"); } //--> </script>

Then you want to remove the code
Code:
{$lang->welcome_back}

and replace with
Code:
<a href="{$mybb->settings['bburl']}/member.php?action=profile" id="edit_post_{$post['pid']}" > <strong> {$mybb->user['username']} </strong >

Source & Credit: Burned Designs


RE: Adding a Dynamic Welcome Message - Expels - 12-24-2013

nice Smile I have no clue what any of this means but It looks cool xD


RE: Adding a Dynamic Welcome Message - 0xDEAD10CC - 02-23-2014

This would be a bad way of doing it IMO... MyBB variables do exist, and thus this implementation should be on the PHP side. A better way would be to look at the $mybb->user['timezone'] and $mybb->user['dst'] variables and edit the PHP directly...

(original) global.lang.php:
Code:
$l['welcome_back'] = "<strong>Welcome back, {1}</strong>. You last visited: {2}";

(original) global.php:
Code:
$lang->welcome_back = $lang->sprintf($lang->welcome_back, build_profile_link($mybb->user['username'], $mybb->user['uid']), $lastvisit);

(modified) global.lang.php:
Code:
$l['welcome_back'] = "<strong>{1}, {2}</strong>. You last visited: {3}";

(modified) global.php:
Code:
$dyn_welcome_msg = ''; // use $mybb->user['timezone'] and $mybb->user['dst'] here // check time // decide what to display for $dyn_welcome_msg $lang->welcome_back = $lang->sprintf($lang->welcome_back, $dyn_welcome_msg, build_profile_link($mybb->user['username'], $mybb->user['uid']), $lastvisit);

This way it would be based on the local time set by the user in the UserCP, and you wouldn't lose MyBB functionality, but rather be adding onto it.

-- With Javascript like this there's no way you can guarantee to match the timezone set via the logged on user's UserCP...

EDIT: Also, why are these in there?
Code:
//-->

Code:
<!--