TinyPortal

Development => Block Codes => Topic started by: elpvn on May 18, 2006, 03:01:02 PM

Title: Show hello message each day
Post by: elpvn on May 18, 2006, 03:01:02 PM
<SCRIPT LANGUAGE="JavaScript">

<!--Begin

datetoday = new Date();
timenow=datetoday.getTime();
datetoday.setTime(timenow);
thehour = datetoday.getHours();
if (thehour > 18) display = "Evening";
else if (thehour >12) display = "Afternoon";
else display = "Morning";
var greeting = ("Good " + display + "!");
document.write(greeting);

//Ã,  End -->

</script>


Put it in a script/html blockÃ,   :)
Title: Re: Show the hello message on day
Post by: akulion on May 19, 2006, 10:55:25 AM
I think this would be nice to have inside the tinyportal "user block" so that it says

"Good Morning"
Welcome Guest (or user - when logged in)

And change according to time of day :D

added to Block code snippet under "w" welcome message
Title: Re: Show the hello message on day
Post by: Crip on May 19, 2006, 11:20:47 AM
Demo? >:D
Title: Re: Show the hello message on day
Post by: technodragon73 on May 19, 2006, 03:22:57 PM
To put it into the userbox:

In TPortalBlocks.template.php

Find:
// Tportal userbox
function TPortal_userbox()
{
          global $context, $settings, $options, $scripturl, $txt, $modSettings;

$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet3 = '<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet4 = '<img src="'.$settings['images_url'].'/tpgoto.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet5 = '<img src="'.$settings['images_url'].'/tpmodule2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

        echo'<table width="99%" cellpadding="0" cellspacing="5" border="0"><tr>';
        echo '<td width="100%" valign="top" class="smalltext" style="font-family: verdana, arial, sans-serif;">';

        if (!empty($context['user']['avatar']) && isset($context['TPortal']['userbox']['avatar']))
                echo $context['user']['avatar']['image'] . '<br />';

        // If the user is logged in, display stuff like their name, new messages, etc.
        if ($context['user']['is_logged'])
        {

                echo '<span class="normaltext">
                                                        ', $txt['hello_member'], ' <b>', $context['user']['name'], '</b></span>';

                // Only tell them about their messages if they can read their messages!
                if ($context['allow_pm']){
                        echo '<br />'.$bullet.'<a href="', $scripturl, '?action=pm">' .$txt['tp-pm'].' ', $context['user']['messages'], '</a>';
                   if($context['user']['unread_messages']>0)
                        echo '<br />'.$bullet.'<a style="font-weight: bold; " href="', $scripturl, '?action=pm">' .$txt['tp-pm2'].' ',$context['user']['unread_messages'] , '</a>';

                }
                // Are there any members waiting for approval?
                if (!empty($context['unapproved_members']))
                        echo '<br />'.$bullet.'<a href="', $scripturl, '?action=regcenter">'.$txt['tp_unapproved_members'].'<b> '. $context['unapproved_members']  . '</b></a>';

                if(isset($context['TPortal']['userbox']['unread'])){
                      echo '<br />'.$bullet.'<a href="', $scripturl, '?action=unread">' .$txt['tp-unread'].'</a>
                               <br />'.$bullet.'<a href="', $scripturl, '?action=unreadreplies">'.$txt['tp-replies'].'</a>
                               <br />'.$bullet.'<a href="', $scripturl, '?action=profile;u='.$context['user']['id'].';sa=showPosts">'.$txt['tp-showownposts'].'</a>';
               }

                // Is the forum in maintenance mode?
                if ($context['in_maintenance'] && $context['user']['is_admin'])
                        echo '<br /><b>' .$bullet.$txt['tp_maintenace']. '</b>';
                // Show the total time logged in?
                if (!empty($context['user']['total_time_logged_in']) && isset($context['TPortal']['userbox']['logged']))
                {
                        echo '<br />'.$bullet.$txt['tp-loggedintime'] . ' ';

                         echo '<br />'.$context['user']['total_time_logged_in']['days'] . 'd ';
                         echo $context['user']['total_time_logged_in']['hours'] . 'h ';
                         echo $context['user']['total_time_logged_in']['minutes'] .'m';
                }
               if(isset($context['TPortal']['userbox']['time'])){
                     echo '<br />'.$bullet. $context['current_time'];
               }

// module links - do not show if none
if($context['TPortal']['show_download']=='1')
{
echo '<hr /><p style="margin: 4px 0 5px 0;"><img src="'.$settings['images_url'].'/tpmodule.gif" style="margin: 0;" align="absbottom" alt="" />
      <b>'.$txt['tp-admin4'].'</b></p>';
if($context['TPortal']['show_download']=='1')
echo $bullet5.' <a href="'.$scripturl.'?action=tpmod;dl=0">'.$txt['tp-dldownloads'].'</a><br />';
}
// admin parts etc.
             if(!isset($context['TPortal']['can_submit_article']))
                  $context['TPortal']['can_submit_article']=0;
// do not show if none is availalable
if($context['TPortal']['can_submit_article']==1 || allowedTo(array('tp_dlupload','tp_dlmanager','tp_settings','tp_articles','tp_blocks')))
{
echo '<hr /><p style="margin: 4px 0 5px 0;"><img src="'.$settings['images_url'].'/tpoptions.gif" style="margin: 0;" align="absbottom" alt="" />
      <b>'.$txt['tp-tools'].'</b></p>';
              // can we submit an article?
              if($context['TPortal']['can_submit_article']==1 && !allowedTo('tp_articles'))
                       echo $bullet4.'<a href="', $scripturl, '?action=tpmod;sa=submitarticle">' . $txt['tp-submitarticle']. '</a><br />';

// upload a file?
              if(allowedTo('tp_dlupload') || allowedTo('tp_dlmanager'))
                       echo $bullet4.'<a href="', $scripturl, '?action=tpmod;dl=upload">' . $txt['permissionname_tp_dlupload']. '</a><br />';

// tpadmin checks
if (allowedTo('tp_settings'))
echo $bullet4.'<a href="' . $scripturl . '?action=tpadmin;sa=settings">' . $txt['permissionname_tp_settings'] . '</a><br />';
if (allowedTo('tp_blocks'))
echo $bullet4.'<a href="' . $scripturl . '?action=tpadmin;sa=blocks">' . $txt['permissionname_tp_blocks'] . '</a><br />';
if (allowedTo('tp_articles'))
{
echo $bullet4.'<a href="' . $scripturl . '?action=tpadmin;sa=articles">' . $txt['permissionname_tp_articles'] . '</a><br />';
// any submissions?
if($context['TPortal']['submitcheck']['articles']>0)
echo $bullet4.$bullet3.'<a href="' . $scripturl . '?action=tpadmin;sa=submission"><b>' . $context['TPortal']['submitcheck']['articles'] . ' ' .$txt['tp-articlessubmitted'] . '</b></a><br />';
}
if (allowedTo('tp_dlmanager'))
{
echo $bullet4.'<a href="' . $scripturl . '?action=tpmod;dl=admin">' . $txt['permissionname_tp_dlmanager'] . '</a>';
// any submissions?
if($context['TPortal']['submitcheck']['uploads']>0)
echo '<br />'.$bullet4.$bullet3.'<a href="' . $scripturl . '?action=tpmod;dl=adminsubmission"><b>' . $context['TPortal']['submitcheck']['uploads'] . ' ' .$txt['tp-dluploaded'] . '</b></a><br />';
}
}

               echo '</div>';
        }
        // Otherwise they're a guest - so politely ask them to register or login.
        else
        {
                echo '
                                                        ', $txt['welcome_guest'], '<br />
                                                        ', $context['current_time'], '<br />

                                                        <form action="', $scripturl, '?action=login2" method="post" >
                                                                <input type="text" name="user" size="10" /> <input type="password" name="passwrd" size="10" />
                                                                <select name="cookielength">
                                                                        <option value="60">', $txt['smf53'], '</option>
                                                                        <option value="1440">', $txt['smf47'], '</option>
                                                                        <option value="10080">', $txt['smf48'], '</option>
                                                                        <option value="302400">', $txt['smf49'], '</option>
                                                                        <option value="-1" selected="selected">', $txt['smf50'], '</option>
                                                                </select>
                                                                <input type="submit" value="', $txt[34], '" /><br />
                                                                ', $txt['smf52'], '
                                                        </form>';
// module links
echo '<hr /><p style="margin: 4px 0 5px 0;"><img src="'.$settings['images_url'].'/tpmodule.gif" style="margin: 0;" align="absbottom" alt="" />
      <b>'.$txt['tp-admin4'].'</b></p>';
if($context['TPortal']['show_download']=='1')
echo $bullet2.'<a href="'.$scripturl.'?action=tpmod;dl=0">'.$txt['tp-dldownloads'].'</a><br />';
        }
echo '<br /></td></tr></table>';

}


and replace with:
// Tportal userbox
function TPortal_userbox()
{
          global $context, $settings, $options, $scripturl, $txt, $modSettings;

$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet3 = '<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet4 = '<img src="'.$settings['images_url'].'/tpgoto.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet5 = '<img src="'.$settings['images_url'].'/tpmodule2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

        echo'<table width="99%" cellpadding="0" cellspacing="5" border="0"><tr>';
        echo '<td width="100%" valign="top" class="smalltext" style="font-family: verdana, arial, sans-serif;">';

        if (!empty($context['user']['avatar']) && isset($context['TPortal']['userbox']['avatar']))
                echo $context['user']['avatar']['image'] . '<br />';

        // If the user is logged in, display stuff like their name, new messages, etc.
        if ($context['user']['is_logged'])
        {

                echo '<span class="normaltext">
<SCRIPT LANGUAGE="JavaScript">

<!--Begin

datetoday = new Date();
timenow=datetoday.getTime();
datetoday.setTime(timenow);
thehour = datetoday.getHours();
if (thehour > 18) display = "Evening";
else if (thehour >12) display = "Afternoon";
else display = "Morning";
var greeting = ("Good " + display + "!");
document.write(greeting);

//  End -->

</script> <br> <b>', $context['user']['name'], '</b></span>';

                // Only tell them about their messages if they can read their messages!
                if ($context['allow_pm']){
                        echo '<br />'.$bullet.'<a href="', $scripturl, '?action=pm">' .$txt['tp-pm'].' ', $context['user']['messages'], '</a>';
                   if($context['user']['unread_messages']>0)
                        echo '<br />'.$bullet.'<a style="font-weight: bold; " href="', $scripturl, '?action=pm">' .$txt['tp-pm2'].' ',$context['user']['unread_messages'] , '</a>';

                }
                // Are there any members waiting for approval?
                if (!empty($context['unapproved_members']))
                        echo '<br />'.$bullet.'<a href="', $scripturl, '?action=regcenter">'.$txt['tp_unapproved_members'].'<b> '. $context['unapproved_members']  . '</b></a>';

                if(isset($context['TPortal']['userbox']['unread'])){
                      echo '<br />'.$bullet.'<a href="', $scripturl, '?action=unread">' .$txt['tp-unread'].'</a>
                               <br />'.$bullet.'<a href="', $scripturl, '?action=unreadreplies">'.$txt['tp-replies'].'</a>
                               <br />'.$bullet.'<a href="', $scripturl, '?action=profile;u='.$context['user']['id'].';sa=showPosts">'.$txt['tp-showownposts'].'</a>';
               }

                // Is the forum in maintenance mode?
                if ($context['in_maintenance'] && $context['user']['is_admin'])
                        echo '<br /><b>' .$bullet.$txt['tp_maintenace']. '</b>';
                // Show the total time logged in?
                if (!empty($context['user']['total_time_logged_in']) && isset($context['TPortal']['userbox']['logged']))
                {
                        echo '<br />'.$bullet.$txt['tp-loggedintime'] . ' ';

                         echo '<br />'.$context['user']['total_time_logged_in']['days'] . 'd ';
                         echo $context['user']['total_time_logged_in']['hours'] . 'h ';
                         echo $context['user']['total_time_logged_in']['minutes'] .'m';
                }
               if(isset($context['TPortal']['userbox']['time'])){
                     echo '<br />'.$bullet. $context['current_time'];
               }

// module links - do not show if none
if($context['TPortal']['show_download']=='1')
{
echo '<hr /><p style="margin: 4px 0 5px 0;"><img src="'.$settings['images_url'].'/tpmodule.gif" style="margin: 0;" align="absbottom" alt="" />
      <b>'.$txt['tp-admin4'].'</b></p>';
if($context['TPortal']['show_download']=='1')
echo $bullet5.' <a href="'.$scripturl.'?action=tpmod;dl=0">'.$txt['tp-dldownloads'].'</a><br />';
}
// admin parts etc.
             if(!isset($context['TPortal']['can_submit_article']))
                  $context['TPortal']['can_submit_article']=0;
// do not show if none is availalable
if($context['TPortal']['can_submit_article']==1 || allowedTo(array('tp_dlupload','tp_dlmanager','tp_settings','tp_articles','tp_blocks')))
{
echo '<hr /><p style="margin: 4px 0 5px 0;"><img src="'.$settings['images_url'].'/tpoptions.gif" style="margin: 0;" align="absbottom" alt="" />
      <b>'.$txt['tp-tools'].'</b></p>';
              // can we submit an article?
              if($context['TPortal']['can_submit_article']==1 && !allowedTo('tp_articles'))
                       echo $bullet4.'<a href="', $scripturl, '?action=tpmod;sa=submitarticle">' . $txt['tp-submitarticle']. '</a><br />';

// upload a file?
              if(allowedTo('tp_dlupload') || allowedTo('tp_dlmanager'))
                       echo $bullet4.'<a href="', $scripturl, '?action=tpmod;dl=upload">' . $txt['permissionname_tp_dlupload']. '</a><br />';

// tpadmin checks
if (allowedTo('tp_settings'))
echo $bullet4.'<a href="' . $scripturl . '?action=tpadmin;sa=settings">' . $txt['permissionname_tp_settings'] . '</a><br />';
if (allowedTo('tp_blocks'))
echo $bullet4.'<a href="' . $scripturl . '?action=tpadmin;sa=blocks">' . $txt['permissionname_tp_blocks'] . '</a><br />';
if (allowedTo('tp_articles'))
{
echo $bullet4.'<a href="' . $scripturl . '?action=tpadmin;sa=articles">' . $txt['permissionname_tp_articles'] . '</a><br />';
// any submissions?
if($context['TPortal']['submitcheck']['articles']>0)
echo $bullet4.$bullet3.'<a href="' . $scripturl . '?action=tpadmin;sa=submission"><b>' . $context['TPortal']['submitcheck']['articles'] . ' ' .$txt['tp-articlessubmitted'] . '</b></a><br />';
}
if (allowedTo('tp_dlmanager'))
{
echo $bullet4.'<a href="' . $scripturl . '?action=tpmod;dl=admin">' . $txt['permissionname_tp_dlmanager'] . '</a>';
// any submissions?
if($context['TPortal']['submitcheck']['uploads']>0)
echo '<br />'.$bullet4.$bullet3.'<a href="' . $scripturl . '?action=tpmod;dl=adminsubmission"><b>' . $context['TPortal']['submitcheck']['uploads'] . ' ' .$txt['tp-dluploaded'] . '</b></a><br />';
}
}

               echo '</div>';
        }
        // Otherwise they're a guest - so politely ask them to register or login.
        else
        {
                echo '
                                                        ', $txt['welcome_guest'], '<br />
                                                        ', $context['current_time'], '<br />

                                                        <form action="', $scripturl, '?action=login2" method="post" >
                                                                <input type="text" name="user" size="10" /> <input type="password" name="passwrd" size="10" />
                                                                <select name="cookielength">
                                                                        <option value="60">', $txt['smf53'], '</option>
                                                                        <option value="1440">', $txt['smf47'], '</option>
                                                                        <option value="10080">', $txt['smf48'], '</option>
                                                                        <option value="302400">', $txt['smf49'], '</option>
                                                                        <option value="-1" selected="selected">', $txt['smf50'], '</option>
                                                                </select>
                                                                <input type="submit" value="', $txt[34], '" /><br />
                                                                ', $txt['smf52'], '
                                                        </form>';
// module links
echo '<hr /><p style="margin: 4px 0 5px 0;"><img src="'.$settings['images_url'].'/tpmodule.gif" style="margin: 0;" align="absbottom" alt="" />
      <b>'.$txt['tp-admin4'].'</b></p>';
if($context['TPortal']['show_download']=='1')
echo $bullet2.'<a href="'.$scripturl.'?action=tpmod;dl=0">'.$txt['tp-dldownloads'].'</a><br />';
        }
echo '<br /></td></tr></table>';

}



This will add the greeting to the user box for TP (extra bonus! this also includes the birthday greeting mod so if it is a members birthday it will greet them with a special message!) Edit: was part of a modification that included edits to other files as well so i removed it from the above code
Title: Re: Show the hello message on day
Post by: akulion on May 19, 2006, 04:31:50 PM
oohhh nice - thanks :D
Title: Re: Show the hello message on day
Post by: technodragon73 on May 19, 2006, 04:35:08 PM
glad to be of service!

;D
Title: Re: Show the hello message on day
Post by: feral on May 20, 2006, 01:16:51 AM
good work Techno, i've been trying to get around to that for my site for a while but the time just wasn't there. thanks alot
Title: Re: Show the hello message on day
Post by: RoarinRow on May 20, 2006, 02:48:47 AM
Ditto on the demo.   ::)
Title: Re: Show the hello message on day
Post by: technodragon73 on May 20, 2006, 03:55:03 AM
I would say look at mine, but only registered members can see it (guests don't get to see much at my site anymore), but here are some screen shots:
Title: Re: Show the hello message on day
Post by: RoarinRow on May 20, 2006, 03:56:51 AM
That's cool.  Does it get the time of day from their PC?   :up:
Title: Re: Show the hello message on day
Post by: RoarinRow on May 20, 2006, 04:10:33 AM
I got this error:

8: Undefined index: today_is_birthday
File: /forum/Themes/default/TPortal.template.php (eval?)
Line: 280
Title: Re: Show the hello message on day
Post by: technodragon73 on May 20, 2006, 04:21:47 AM
sort of...whatever time you have with the forum compared to your time zone....so it is a hybrid...
Title: Re: Show the hello message on day
Post by: technodragon73 on May 20, 2006, 04:31:15 AM
Sorry, edited the post above.  The birthday greeting was part of an edit that involved other files as well so i removed it...the greeting is still there.
Title: Re: Show the hello message on day
Post by: RoarinRow on May 20, 2006, 05:31:36 AM
Quote from: TechnoDragon on May 20, 2006, 04:31:15 AM
Sorry, edited the post above.  The birthday greeting was part of an edit that involved other files as well so i removed it...the greeting is still there.

Cool, that worked thanks!   8)
Title: Re: Show the hello message on day
Post by: technodragon73 on May 20, 2006, 06:24:41 AM
anytime!
Title: Re: Show the hello message on day
Post by: elpvn on May 20, 2006, 08:40:42 AM
Nice code, Tech  ;D
Title: Re: Show the hello message on day
Post by: pheasant_plucker on May 20, 2006, 06:29:55 PM
I tried this but it doesn't show my avatar in the box! It's stored externaly to the forum server would that stop it showing?

Gerry
Title: Re: Show the hello message on day
Post by: rbh on May 20, 2006, 07:26:24 PM
just curious, but i tried the mod to the template file tech posted and it didn't change anything. i looked at both codes posted and they look the same. am i missing something?
Title: Re: Show the hello message on day
Post by: RoarinRow on May 20, 2006, 07:31:56 PM
Quote from: rbh on May 20, 2006, 07:26:24 PM
just curious, but i tried the mod to the template file tech posted and it didn't change anything. i looked at both codes posted and they look the same. am i missing something?

Tech's code worked for me.  See attached.
Title: Re: Show the hello message on day
Post by: rbh on May 20, 2006, 07:39:29 PM
look back at both codes posted and compare them, i couldnt find any changes between the two.  ??? i copied the second code and changed it within the TPortalBlocks.template.php and it doesn't do anything different.

roarin, can you open your TPortalBlocks.template.php and copy what change you made and post it here?


sorry, i was the one messing up. i copied the wrong thing. :o  :uglystupid2: ok, i will try again. thanks!

it works great! ;D
Title: Re: Show the hello message on day
Post by: RoarinRow on May 20, 2006, 08:27:43 PM
Quote from: rbh on May 20, 2006, 07:39:29 PM
look back at both codes posted and compare them, i couldnt find any changes between the two.  ??? i copied the second code and changed it within the TPortalBlocks.template.php and it doesn't do anything different.

roarin, can you open your TPortalBlocks.template.php and copy what change you made and post it here?


sorry, i was the one messing up. i copied the wrong thing. :o  :uglystupid2: ok, i will try again. thanks!

it works great! ;D

Been there, done that.   :2funny:
Title: Re: Show the hello message on day
Post by: technodragon73 on May 21, 2006, 03:48:47 AM
glad to see it worked out!
Title: Re: Show the hello message on day
Post by: rjholla2003 on August 17, 2006, 06:43:49 PM
Just to clarify things because somehow I got confused.  If I add this snippet, will it also include a "happy birthday" message on a user's birthday?  If not, could I tie in this snippet (http://www.tinyportal.net/smf/index.php?topic=3417.0) to have that work?
Title: Re: Show the hello message on day
Post by: Max on August 17, 2006, 06:51:50 PM
Quote from: rjholla2003 on August 17, 2006, 06:43:49 PM
If I add this snippet, will it also include a "happy birthday" message on a user's birthday?

No.. unless you add the 2 seperate codes ;)
Title: Re: Show hello message each day
Post by: technodragon73 on August 18, 2006, 04:12:25 AM
yes, you can add both codes to do what you ask...I have and it has been a hit with my members.
Title: Re: Show hello message each day
Post by: yjobcreations on October 04, 2006, 11:15:50 AM
i would like to suggest that there is also a code that changes the greeting in the user box (not the one in the block, but the original user info at the top header).

to have a clearer detail on what i meant, try shnging to the Babylon theme, there you will see the original user box at the top, so you will have two user boxes, the one at the top and the one in the Tportal block.

some themes can not remove the one at the top therefore your other userbox will say Good Afternoon! while the other one at the top would say Hey,.
Title: Re: Show hello message each day
Post by: Kiwitje on October 10, 2006, 02:22:09 AM
Damn, so nice! haha. Thanks mate!
Title: Re: Show hello message each day
Post by: technodragon73 on October 10, 2006, 05:09:34 AM
actually I have both on the default theme...I have to look at where the other code goes, but it can be done!
Title: Re: Show hello message each day
Post by: tamasir on October 16, 2006, 10:04:37 PM
Vauuu! nice - thanks  :up:
tamasir~
Title: Re: Show hello message each day
Post by: Joramilea on October 16, 2006, 10:59:24 PM
Ok this is too cool!  I am going to have to try this out on my forums!

**edit**
I just put this up on my site.  copyed the text and placed it where it should go.  But I am thinking I missed something.

Is says Good Afternoon no matter what time my profile is changed to.  I knowticed this off the bat because it's 6:40pm on my forum and it said Good Afternoon.   :o
Title: Re: Show hello message each day
Post by: babjusi on May 16, 2007, 12:37:16 AM
neat, thanks
Title: Re: Show hello message each day
Post by: purplegold on May 25, 2007, 06:09:20 PM
I have version 9.8, I was wondering if the code is different in the TPortalBlank.template.php. SInce i can't seem to find it or i'm just slightly  :idiot2: