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,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 728
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 376
  • Total: 376

Greetings: Birthday, Holiday, Time of Day

Started by JPDeni, October 22, 2006, 11:48:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

houston

 :up: Thanks JPdeni that was the ticket.

Cheers


technodragon73

Ok, seeing as how it is halloween today (in the us) I have that as an extra holiday in the greetings file.  Now the problem I have is that the appropriate greeting is showing (Happy Halloween), but the image is not showing up...no error, no missing image box...nothing...did i miss something?

JPDeni

Do you have the image defined? You should have

$txt['img']['halloween']['all'] = 'pumpkin.gif';

(or something similar with the name of your image file) defined in your Greetings.english.php file. It's set up that way so that you don't have to have an image for every holiday if you don't want one.

technodragon73

Yes I do actually...
Here is exactly what is in my greetings file:
$txt['halloween']['all'] = 'Happy Halloween';
$txt['img']['halloween']['all'] = 'pumpkin.gif';


and the image is in the smiley directory like the time of day ones and they work fine...btw the birthday one worked as well.

JPDeni

#25
It would probably help if I had the code right.  :uglystupid2:

Change
 
      if ($greeting > '')
      {
        if (isset($img[$holiday][$country]))
          $image = $img[$holiday][$country];
        elseif (isset($img[$holiday]['all']))
          $image = $img[$holiday]['all'];
      }


to this

 
      if ($greeting > '')
      {
        if (isset($txt['img'][$holiday][$country]))
          $image = $txt['img'][$holiday][$country];
        elseif (isset($txt['img'][$holiday]['all']))
          $image = $txt['img'][$holiday]['all'];
      }


I'll go fix it in the original. Sorry 'bout that.

technodragon73


JPDeni

I've done a little editing of the code. It was bothering me that there might be days when there is more than one holiday or birthdays might fall on a holiday. So, in those instances, it prints out an appropriate random greeting each time the page is reloaded. It also includes code to wish a happy anniversary to members on the anniversary of their membership on the forum. It's conceivable that you could have two holidays, a birthday and an anniversary all on the same day, so each of the greetings for that person has a one in four chance of showing up each time the page is reloaded.

If you want to include the changes, you'll need to copy over the greetings function in its entirety. (The changes have been made to the code in the first post of this topic.) The only change you'll need to make to the Greetings.english.php file (or other language files you may have created) is to add the ['all'] key to the birthday text and image and to add text for the anniversary greeting, if you want to use it:

$txt['birthday']['all'] = 'Happy birthday';
$txt['img']['birthday']['all'] = 'bday.gif';
$txt['anniversary']['all'] = 'Happy Anniversary';
$txt['img']['anniversary']['all'] = 'bday.gif';


I'll likely come up with another tweak later on, too.   :)

technodragon73


JPDeni

I don't understand.

The function that you have now needs to be replaced by the code which is now in the first message of this topic. I've edited that first message so that it has the latest code.

This website is proudly hosted on Crocweb Cloud Website Hosting.