Main Menu
collapse

Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

User Info

Welcome Guest.
Please log in.

Who's Online

  • Dot Guests: 1327
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]


Thanks for having an interest with our portal. If you have any requests for features, have a look at the Feature Requests board.

Modified CalendarInformation block

Started by Hannilein, May 08, 2009, 05:17:45 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Hannilein

Hello,
first of all I want to thank you for this great and 'simple' to use portal. I added it some days ago to my little forum and I have fun with it.

Especially for the block 'CalendarInformation' I found some issues which made me feel uncomfortable, so I modified it (I should say that I'm relatively new to PHP programming so maybe the coding style of my mods are not perfect...).

1. If a event line breaks, the second part of the line displays below the icon. This looks bad. I modified it to use tables to make the line break look better.

2. With my settings the block shows the upcoming events of the next 14 days. If there is a multiple-day-event, it is displayed several times in the block. I modified it to display only once, together with the duration of the event.

Attached is my modified code of the function 'sp_calendarInformation' in the file 'SPortal1-1.php':

(my mods are marked with 'inserted by DiSc' or 'mod DiSc')

function sp_calendarInformation($parameters, $id, $return_parameters = false)
{
global $scripturl, $modSettings, $txt;

$block_parameters = array(
'events' => 'check',
'future' => 'int',
'birthdays' => 'check',
'holidays' => 'check',
);

if ($return_parameters)
return $block_parameters;

$show_event = !empty($parameters['events']);
$event_future = (int) $parameters['future'];
$event_future = abs($event_future);
$show_birthday = !empty($parameters['birthdays']);
$show_holiday = !empty($parameters['holidays']);
$show_titles = false;

if (!$show_event && !$show_birthday && !$show_holiday)
{
echo '
', $txt['sp_calendar_noEventsFound'];
return;
}

$now = forum_time();
$today_date = date("Y-m-d", $now);
$calendar_array = array(
'todayEvents' => array(),
'futureEvents' => array(),
'todayBirthdays' => array(),
'todayHolidays' => array()
);

    // inserted by DiSc
$shown = array();

if ($show_event)
{
if (!empty($event_future))
$event_future_date = date("Y-m-d", ($now + $event_future * 86400));
else
$event_future_date = $today_date;

$events = sp_loadCalendarData('getEvents', $today_date, $event_future_date);

if (!empty($events[$today_date]))
{
$calendar_array['todayEvents'] = $events[$today_date];
unset($events[$today_date]);
}

if (!empty($events))
{
ksort($events);
$calendar_array['futureEvents'] = $events;
}
}

if ($show_birthday)
{
$calendar_array['todayBirthdays'] = current(sp_loadCalendarData('getBirthdays', $today_date));
$show_titles = !empty($show_event) || !empty($show_holiday);
}

if ($show_holiday)
{
$calendar_array['todayHolidays'] = current(sp_loadCalendarData('getHolidays', $today_date));
$show_titles = !empty($show_event) || !empty($show_birthday);

if (timeformat(forum_time(), '%d-%m') == '25-08')
$calendar_array['todayHolidays']['e'] = base64_decode('RWxpYW5hIERheQ==');
}

if (empty($calendar_array['todayEvents']) && empty($calendar_array['futureEvents']) && empty($calendar_array['todayBirthdays']) && empty($calendar_array['todayHolidays']))
{
echo '
', $txt['sp_calendar_noEventsFound'];
return;
}
else

    /*
echo '
<ul class="sp_list">';
*/

        /*
if (!empty($calendar_array['todayHolidays']))
{
if ($show_titles)
echo '
<li><strong>', $txt['sp_calendar_holidays'] ,'</strong></li>';

foreach ($calendar_array['todayHolidays'] as $key => $holiday)
echo '
<li>', sp_embed_image($key === 'e' ? 'diamond' : 'holiday'), ' ', $holiday ,'</li>';
}
*/

/* mod DiSc */
if (!empty($calendar_array['todayHolidays']))
{
echo '
    <table cols=2>';
   
if ($show_titles)
{
echo '
<tr>
                        <td colspan="2">
<strong>', $txt['sp_calendar_holidays'] ,'</strong>
</td>
</tr>
                    ';
            }

        foreach ($calendar_array['todayHolidays'] as $key => $holiday)
    echo '
        <tr>
                            <td style="width:16px">',
                                sp_embed_image($key === 'e' ? 'diamond' : 'holiday'),'
                            </td>
                            <td style=align:left">',
$holiday,'
                            </td>
        </tr>
        ';
echo '
</table>
    ';
}


        /*
if (!empty($calendar_array['todayBirthdays']))
{
if ($show_titles)
echo '
<li><strong>', $txt['sp_calendar_birthdays'] ,'</strong></li>';

foreach ($calendar_array['todayBirthdays'] as $member)
echo '
<li>', sp_embed_image('birthday'), ' <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a></li>';
}
*/

/* mod DiSc */
if (!empty($calendar_array['todayBirthdays']))
{
echo '
    <table cols=2>';

if ($show_titles)
{
echo '
<tr>
                        <td colspan="2">
<strong>', $txt['sp_calendar_birthdays'] ,'</strong>
</td>
</tr>
                    ';
            }

        foreach ($calendar_array['todayBirthdays'] as $member)
    echo '
        <tr>
                            <td style="width:16px">',
                                sp_embed_image('birthday'),'
                            </td>
                            <td style=align:left">
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>
                            </td>
        </tr>
        ';
echo '
</table>
    ';
}

/*
if (!empty($calendar_array['todayEvents']))
{
if ($show_titles)
echo '
<li><strong>', $txt['sp_calendar_events'] ,'</strong></li>';

foreach ($calendar_array['todayEvents'] as $event)
echo '
<li>', sp_embed_image('event'), ' ', $event['link'], !$show_titles ? ' - ' . timeformat(forum_time(), '%d %b') : '', '</li>';
}
*/

/* mod DiSc */
if (!empty($calendar_array['todayEvents']))
{
echo '
    <table cols=2>';

if ($show_titles)
{
echo '
<tr>
                        <td colspan="2">
<strong>', $txt['sp_calendar_events'] ,'</strong>
</td>
</tr>
                    ';
            }

        foreach ($calendar_array['todayEvents'] as $event)
    echo '
        <tr>
                            <td style="width:16px">',
                                sp_embed_image('event'),'
                            </td>
                            <td style=align:left">',
                                $event['link'],'
                            </td>
        </tr>
        ';
echo '
</table>
    ';
}

        /*
if (!empty($calendar_array['futureEvents']))
{
if ($show_titles)
echo '
<li><strong>', $txt['sp_calendar_upcomingEvents'] ,'</strong></li>';

foreach($calendar_array['futureEvents'] as $startdate => $events)
{
list($year, $month, $day) = explode('-', $startdate);
$currentDay = $day . '. ' . $txt['months_short'][(int) $month];

foreach($events as $event)
echo '
<li>', sp_embed_image('event'), ' ', $event['link'], ' - ', $currentDay;
}
}
*/
/* mod DiSc */
if (!empty($calendar_array['futureEvents']))
{
echo '
    <table cols=2>';
   
if ($show_titles)
{
echo '
<tr>
                        <td colspan="2">
<strong>', $txt['sp_calendar_upcomingEvents'] ,'</strong>
</td>
</tr>
                    ';
            }
foreach($calendar_array['futureEvents'] as $startdate => $events)
{
list($year, $month, $day) = explode('-', $startdate);
$currentDay = $day . '. ' . $txt['months_short'][(int) $month];

foreach($events as $event)
{
    list($year, $month, $day) = explode('-', $event['start_date']);
        $firstDay = $day . '. ' . $txt['months_short'][(int) $month];
                list($year, $month, $day) = explode('-', $event['end_date']);
      $lastDay = $day . '. ' . $txt['months_short'][(int) $month];

    if (!in_array($event['id'],$shown))
    {
        array_push($shown,$event['id']);
        echo '
          <tr>
                             <td style="width:16px">',
                                    sp_embed_image('event'),'
                                </td>
                                <td>',
                                    $event['link'],'<br />',
                                    $event['start_date'] != $event['end_date'] ? $firstDay. ' - ' . $lastDay : $txt['sp-dateat'] . $currentDay,'   
                                </td>
          </tr>
            ';
        /*
        echo '
          <tr>
                             <td style="width:16px">',
                                    sp_embed_image('event'),'
                                </td>
                                <td>',
                                    //$event['link'], '<br />', $currentDay,'
                                    $event['link'],'
                                </td>
          </tr>
          <tr>
                             <td style="width:16px">&nbsp;</td>
                                <td  style="vertical-align:top">',
                                    $event['start_date'] != $event['end_date'] ? $firstDay. ' - ' . $lastDay : $txt['sp-dateat'] . $currentDay,'   
                                </td>
          </tr>
            ';
            */
            }
            }
        }
echo '
</table>
    ';
}




        /*
echo '
</ul>';
*/
}
}


Not to forget, there is also a new language text entry needed:

$txt['sp-dateat'] = 'at ';


Kind regards, Dirk

p.s. Special regards to Eliana ;)

[SiNaN]

First of all; welcome to SimplePortal!

1. Actually lists are the -semantically- most appropriate tags to use when listing events. However, the issue arises from the image not being a bullet icon, but an image. This was designed in this way so that there could be a fallback to default. If you are happy with your result, that's great.

2. That issue was reported sometime ago here and a fix is included. It will be fixed with the 2.2.1 version.

P.S. I hope that "regards" is not for something you shouldn't have seen. :P
And slowly, you come to realize... It's all as it should be...

Hannilein

Thank your for welcoming and your reply.

Quote from: [SiNaN] on May 08, 2009, 06:49:49 AM
1. Actually lists are the -semantically- most appropriate tags to use when listing events. However, the issue arises from the image not being a bullet icon, but an image. This was designed in this way so that there could be a fallback to default. If you are happy with your result, that's great.
I found this behaviour (bad line breaks in lists) also in other block (e.g. 'Top Posters') and modified it also. Works fine for me, although maybe there will be some issues with upgrading later (?) :0

Quote2. That issue was reported sometime ago here and a fix is included. It will be fixed with the 2.2.1 version.
Sorry for missing it. Certainly my mod and this fix will do almost the same, but I like also the displaying of the duration of the event :D

QuoteP.S. I hope that "regards" is not for something you shouldn't have seen. :P
I will not squeal about  ;P

Regards,
Dirk

[SiNaN]

QuoteI found this behaviour (bad line breaks in lists) also in other block (e.g. 'Top Posters') and modified it also. Works fine for me, although maybe there will be some issues with upgrading later (?) :0

Top Posters block uses tables. So it should be fine I guess. Would you provide a screen shot?

No, you won't have issues. Except that you'll loose the changes you made in SimplePortal source files, including this. I can suggest that you add these codes as a PHP block and you won't loose them on upgrades.

QuoteI will not squeal about  ;P

Okay, no problems then. :D
And slowly, you come to realize... It's all as it should be...

Hannilein

Quote from: [SiNaN] on May 09, 2009, 05:16:08 AM
Top Posters block uses tables. So it should be fine I guess. Would you provide a screen shot?
Oh sorry, my mistake. You see I'm already confused about my changes  ;) . I modified it to remove displaying the resized avatars, because my forum is hosted by a free hoster and there dynamically resized (also with "<img width=...") images are forbidden  :'(

For a live demo (instead of screenshot) please click the link to my little forum in my signature. The 'TopPosters' block is named "Schreiber der Woche" and the 'CalendarInformation' is named "Ereignisse".

Kind regards,
Dirk

[SiNaN]

I see you turned them into a regular list. I was curious if it was an error at SP end.
And slowly, you come to realize... It's all as it should be...