yohang / CalendR

The missing PHP 5.3+ calendar management library.
http:/yohan.giarel.li/CalendR
MIT License
465 stars 65 forks source link

Multi-day Events #35

Closed spib closed 8 years ago

spib commented 10 years ago

Hi,

How do you show multi-day events on a calendar? The following piece of code correctly shows events which start on a particular date, but it doesn't show events which span multiple days. I'm using the Indexed Event Collection.

<?php foreach ($eventCollection->find($day) as $event): ?>
    <li><?= $event ?></li>
<?php endforeach ?>

Thanks

GDmac commented 8 years ago

Take a look at the find() method of the indexed collection and of basic collection. Indexed Collection only stores and finds events in an array with keys derived from eventBegin. The basic collection actually has some logic in its find() method to lookup period->containsEvent() or event->contains(date) etc.

So, your $eventCollection->find($day) only finds events under its array this->events[$day].

  1. How are you creating/retrieving your collection?
  2. You can supply your provider to Calendar and getEvents() to retrieve a basic collection
  3. Or you can retrieve an array from your own provider
$collection = $calendar->getEvents($period);
// or
$array = $provider->getEvents($DateTimeStart, $DateTimeEnd);
spib commented 8 years ago

Thanks, this is an old issue and I'm no longer using this module so the issue can be closed