Welcome Message Timing: Revision

Last updated by Trajan

I decided that seeing the "Welcome username" on the dashboard every  time was a little boring for me, so I decided to update it with a tiny little Javascript. On my site, it now reads the time and responds with a "Good Morning/Afternoon/Evening username" instead. 

If this is something you're interested in then follow my simple instructions:

GOTO root/mod/riverdashboard/views/default/riverdashboard/welcome.php

Save the file as a backup (save to a different location - but remember where)

Now copy the following code and overwrite everything in the <div> of that file:

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

datetoday = new Date();

timenow=datetoday.getTime();

datetoday.setTime(timenow);

thehour = datetoday.getHours();

if (thehour > 18) display = "<?php echo elgg_echo('riverdashboard:greeting:evening');?>";

else if (thehour >12) display = "<?php echo elgg_echo('riverdashboard:greeting:afternoon');?>";

else display = "<?php echo elgg_echo('riverdashboard:greeting:morning');?>";

var greeting = (display);

//  End -->

</script>

 

<div id="content_area_user_title">

<h2><?php echo sprintf("<script>document.write(greeting);</script>".$_SESSION['user']->name); ?></h2>

</div>

Save and then GOTO root/mod/riverdashboard/languages/en.php

Add the following code:

'riverdashboard:greeting:evening' => "Good evening ",

'riverdashboard:greeting:afternoon' => "Good afternoon ",

'riverdashboard:greeting:morning' => "Good morning ",

Save...that's it. 

Go and check out your dashboard and see what it says now.

Expansion:

Even a non-Javascript coder (like myself) can edit this to change the timing. Look in the Javascript at the top of the file and find the if elseif else lines. Change the numbers there (24hours) to whatever you like. You can of course add or delete lines if you like. 

Warning: If you only want 2 calls remove the elseif line. If you want more than 3 calls copy the elseif line and change the numbering and elgg_echo to what you want.

Enjoy!

 

History