TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,985
  • Total Topics: 21,321
  • Online today: 781
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 693
  • Total: 693

Greeting Block

Started by rjackson, April 22, 2006, 03:24:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bobbyplant

Hi thanks for the reply. The docs page offers examples but the links dont work??

Im struggling to get anything to appear :laugh:

JPDeni

Do you have TinyPortal installed? If not, install it before going any further.

Go to your admin interface. Look for a section labeled TinyPortal. Under that will be a link labeled Block Manager. Click it.

From there, you can create a new block. You'll want a php block. Paste the code into the block. Save it. Then, on the main list of blocks be sure to activate it -- click the green button by the block.

If you have problems with any of this, you can ask questions, but you will need to be specific with what you have done and what the problem is.

lOOmis

I can't seem to find the file...

"It can, but you have to edit the TPortalBlocks.template.php file."

Is it accessable from the Current Theme?

Thanks,
lOOmis

Bobbyplant

Quote from: JPDeni on March 06, 2008, 10:20:10 PM
Do you have TinyPortal installed? If not, install it before going any further.

Go to your admin interface. Look for a section labeled TinyPortal. Under that will be a link labeled Block Manager. Click it.

From there, you can create a new block. You'll want a php block. Paste the code into the block. Save it. Then, on the main list of blocks be sure to activate it -- click the green button by the block.

If you have problems with any of this, you can ask questions, but you will need to be specific with what you have done and what the problem is.

Thanks for your help, got it sorted!

JPDeni

lOOmis, what file are you talking about? You don't need to find a file to create a block. You just create it.

Bobbyplant, Cool!! :)

lOOmis

This is what I was asking about. Is it part of the Template CSS? I got the origianl code inserted into a php block. Worked great. I would like to add the code below.

Quote from: JPDeni on August 16, 2006, 11:55:33 PM
It can, but you have to edit the TPortalBlocks.template.php file.

Here's what I did. Down at the bottom of the file, I added
function greeting()
{
  global $user_info;
  $return = '';
  $hour = date('G') + $user_info['time_offset'];
  if ($hour > 23) { $hour = $hour - 24; }
  elseif ($hour < 0) { $hour = $hour + 24; }
  $name = $user_info['username'];
  if($hour >= 0 && $hour <= 7)
  {
        $return = "Very early, isnt it, <b>$name</b>?";
  }
  else if($hour <= 8 && $hour <= 12)
  {
        $return =  "Good morning, <b>$name</b>!";
  }
  else if($hour >= 13 && $hour <= 16)
  {
        $return =  "Good afternoon, <b>$name</b>!";
  }
  else if($hour >= 17 && $hour <= 23)
  {
        $return =  "Good evening, <b>$name</b>!";
  }
  return $return;
}


Then under function userbox(), find

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


Change it to

                echo '<span class="normaltext">
                                                        ', greeting(), '</b></span>';


It works for me.

ApplianceJunk

Cool!

Works great for us, thanks!

JPDeni

lOOmis, you'll have to edit the TPortalBlocks.template.php in a text editor.

lOOmis

OK, Thankyou. I was looking everywhere in the Admin Section to get to it....oh well. Not ready to tackle that.

Thanks again for the help.

lOOmis

Solomon

JPDeni
Thanks, this is a neat and friendly piece of coding :)

This website is proudly hosted on Crocweb Cloud Website Hosting.