News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

How to show the upcoming birthdays, at home, with the calendar OFF?

Started by luuuciano, January 07, 2011, 12:08:42 PM

Previous topic - Next topic

luuuciano

Hi!

I do not want to use the full set of calendar features (events, post -> events vinculation, etc)... I just need a list of upcoming birthday at the main board section...

I have tried adding a few comments to the BoardIndex.template.php file, to force it to show...
But it looks like $context['calendar_birthdays'] is allways empty when Calendar if OFF?

Any idea about how to achieve this?
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

hadesflames

No, this would require a mod to make it work without the calendar being on. I suggest you ask for one in the mod request board, or see if one already exists that does this.

luuuciano

Yep... well, before posting this I have searched for "birthday" in the mod directory, without luck...

Will do the mod request, as soon as I can :)
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

hadesflames


feline

Here a small code part to show birthdays for the current month even if the calendar off ..


global $smcFunc, $scripturl, $sourcedir, $txt;

include_once($sourcedir .'/Subs-Calendar.php');
$month = (int) strftime('%m', forum_time());
$year = (int) strftime('%Y', forum_time());

$start_data = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year));
if($month == 12)
{
   $month = 1;
   $year++;
}
else
   $month++;
$end_data = date('Y-m-d', mktime(0, 0, 0, $month, 0, $year));

$calbirthdays = getBirthdayRange($start_data, $end_data);
ksort($calbirthdays);

foreach($calbirthdays as $cdate => $data)
{
   list($cdt['year'], $cdt['month'], $cdt['day']) = explode('-', $cdate);
   foreach($data as $vals)
      echo $smcFunc['substr']($txt['months'][intval($cdt['month'])], 0, 3) .' '. $cdt['day'] .': <a href="'. $scripturl .'?action=profile;u='. $vals['id'] .'">'. $vals['name'] .(!empty($vals['age']) ? '('. $vals['age'] .')' : '') .'</a><br />';
}


Fel

luuuciano

I have tried and it works great! I will need to reformat the output of course...

Thanks a lot feline!

btw. this should be added to the tips section/list, or something, at least...
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

luuuciano

feline, after a couple of days I saw this errors in the logs:

2: Invalid argument supplied for foreach()
File: /home/username/public_html/foros/Themes/default/BoardIndex.template.php
Línea: 394

Any idea? what to do?
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

feline

please post the code for exact this line .. the I can check that.

Fel

luuuciano

Oops, sorry, here it is:


if (!$context['user']['is_guest'])
{
echo '
<span class="birthday">Cumpleaños de este mes:</span>
<p class="smalltext">';

global $smcFunc, $scripturl, $sourcedir, $txt;

include_once($sourcedir .'/Subs-Calendar.php');
$month = (int) strftime('%m', forum_time());
$year = (int) strftime('%Y', forum_time());

$start_data = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year));
if($month == 12)
{
   $month = 1;
   $year++;
}
else
   $month++;
$end_data = date('Y-m-d', mktime(0, 0, 0, $month, 0, $year));

$calbirthdays = getBirthdayRange($start_data, $end_data);
ksort($calbirthdays);

foreach($calbirthdays as $cdate => $data)
{
   list($cdt['year'], $cdt['month'], $cdt['day']) = explode('-', $cdate);
   foreach($data as $vals)
//      echo $smcFunc['substr']($txt['months'][intval($cdt['month'])], 0, 3) .' '. $cdt['day'] .': <a href="'. $scripturl .'?action=profile;u='. $vals['id'] .'">'. $vals['name'] .(!empty($vals['age']) ? '('. $vals['age'] .')' : '') .'</a><br />';
      echo $smcFunc['substr']($txt['months'][intval($cdt['month'])], 0, 3) .' '. $cdt['day'] .', <a href="'. $scripturl .'?action=profile;u='. $vals['id'] .'">'. $vals['name'] .(!empty($vals['age']) ? ' ('. $vals['age'] .')' : '') .'</a>. ';
}


line 394 is "foreach($calbirthdays as $cdate => $data)"
the commented echo is your original example
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

feline

Pleae check follow:

if(is_array($calbirthdays))
{
foreach($calbirthdays as $cdate => $data)
{
list($cdt['year'], $cdt['month'], $cdt['day']) = explode('-', $cdate);
foreach($data as $vals)
echo $smcFunc['substr']($txt['months'][intval($cdt['month'])], 0, 3) .' '. $cdt['day'] .', <a href="'. $scripturl .'?action=profile;u='. $vals['id'] .'">'. $vals['name'] .(!empty($vals['age']) ? ' ('. $vals['age'] .')' : '') .'</a>. ';
}
}


Fel

luuuciano

oops!
Its not doing those errors again (without change anything...)
maybe it was an old code or something... will check in a few days!

thanks a lot!
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

Advertisement: