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, 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.
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 :)
Meanwhile, I'll mark this topic as solved ;)
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
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...
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?
please post the code for exact this line .. the I can check that.
Fel
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
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
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!