TinyPortal

Development => Block Codes => Topic started by: yjobcreations on March 08, 2007, 04:25:56 AM

Title: How to display Birthdays without ","
Post by: yjobcreations on March 08, 2007, 04:25:56 AM
i used this function:

ssi_todaysBirthdays();

it displays:

birthday1, birthday2, birthday3

i want it to display:

Birthday1
Birthday2
Birthday3


How?  :-\
Title: Re: How to display Birthdays without ","
Post by: technodragon73 on March 08, 2007, 05:12:15 AM
edit the ssi code that determines birthdays. (not recommended though)
Title: Re: How to display Birthdays without ","
Post by: JPDeni on March 08, 2007, 12:18:34 PM
The other thing you can do, especially if you want it in a block, is to copy the SSI code, paste it into a block and edit the code there.


global $context, $scripturl;

require_once ("SSI.php");

if (!smf_loadCalendarInfo() || empty($context['calendar_birthdays']))
  echo 'No birthdays today';
else {
  foreach ($context['calendar_birthdays'] as $member)
    echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? '<br />' : '');
}
Title: Re: How to display Birthdays without ","
Post by: yjobcreations on March 08, 2007, 03:10:19 PM
thank you :)
Title: Re: How to display Birthdays without ","
Post by: JPDeni on March 08, 2007, 06:11:06 PM
You're welcome. :)
Title: Re: How to display Birthdays without ","
Post by: yjobcreations on March 08, 2007, 09:39:26 PM
JPDeni i there is one error in the code.

echo 'No birthdays today";

i replaced " with '

:)

----

by the way, how about the holidays and events?
i thought i would be nice to include them too and list in one line each like the birthdays.

thanks again.
Title: Re: How to display Birthdays without ","
Post by: JPDeni on March 09, 2007, 06:22:36 AM
Good job for noticing. I'll fix it in the original code. I also made another small change that might make a difference.

Do you want them all in the same block or separate ones? For the same block, use


global $context, $scripturl;

require_once ("SSI.php");

if (!smf_loadCalendarInfo() || empty($context['calendar_birthdays']))
  echo 'No birthdays today';
else {
  foreach ($context['calendar_birthdays'] as $member)
    echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? '<br />' : '');
}

if (!smf_loadCalendarInfo() || empty($context['calendar_holidays']))
  echo 'No holidays today';
else
  echo implode('<br />', $context['calendar_holidays']);

if (!smf_loadCalendarInfo() || empty($context['calendar_events']))
  echo 'No events';
else {
  foreach ($context['calendar_events'] as $event) {
    if ($event['can_edit'])
      echo '
        <a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ';
    echo '
      ' . $event['link'] . (!$event['is_last'] ? '<br />' : '');
  }
}


If you want three separate, use

Holidays:


global $context;
require_once ("SSI.php");
if (!smf_loadCalendarInfo() || empty($context['calendar_holidays']))
  echo 'No holidays today';
else
  echo implode('<br />', $context['calendar_holidays']);


Events:


global $context;
require_once ("SSI.php");
if (!smf_loadCalendarInfo() || empty($context['calendar_events']))
  echo 'No events';
else {
  foreach ($context['calendar_events'] as $event)  {
    if ($event['can_edit'])
      echo '
        <a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ';
    echo '
      ' . $event['link'] . (!$event['is_last'] ? '<br />' : '');
  }
}
Title: Re: How to display Birthdays without ","
Post by: yjobcreations on March 09, 2007, 11:34:49 AM
thanks.

i combined it with the Calendar block to display the names and events one line per entry.  the original code in the Calendar displays the entries continously separating them with commas.