# How to handle multi-date events as separate pages

**URL:** <https://forum.getkirby.com/t/how-to-handle-multi-date-events-as-separate-pages/32635>\
**Category:** Questions\
**Created:** [October 8, 2024, 8:25am UTC](https://forum.getkirby.com/t/how-to-handle-multi-date-events-as-separate-pages/32635 "2024-10-08T08:25:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![breaddes](https://avatars.discourse-cdn.com/v4/letter/b/e47c2d/32.png) [@breaddes](https://forum.getkirby.com/u/breaddes)\
**Post date:** [October 8, 2024, 8:25am UTC](https://forum.getkirby.com/t/how-to-handle-multi-date-events-as-separate-pages/32635/1 "2024-10-08T08:25:58Z")

</div>

I have events master pages that have multiple dates that are maintained via structured fields. Subpages for the events seemed too cumbersome to me.

However, it is now the case that each event should actually be its own page. The call should not be a problem with a custom route from slug and date.

However, I am having difficulties with the template overviews. At the moment I’m using a loop through the dates to create duplicates of the page and add the date as an object variable. Is there a better solution?

```auto
foreach($events as $event){

  $dates = $event->dates()->toStructure();

  foreach($dates as $date){

    $eventDate = $date->date()->toDate('Ymd');
    $eventTime = $date->time();
    $eventLocation = $date->location();
    $toDate = date( "Ymd" , strtotime("now +4 Weeks"));

    if($eventDate <= $toDate && $eventDate >= date("Ymd")){
      $eventClone = clone $event;
      $eventClone->eventDate = $eventDate;
      $eventClone->eventLocation = $eventLocation;
      $eventClone->eventTime = $eventTime;
      $sortedEvents[] = $eventClone;
    }
  }
}

usort($sortedEvents, function($a, $b) {
  return $a->eventDate <=> $b->eventDate;
});

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [October 8, 2024, 11:14am UTC](https://forum.getkirby.com/t/how-to-handle-multi-date-events-as-separate-pages/32635/2 "2024-10-08T11:14:46Z")

</div>

See [Add the same page to a collection multiple times](https://forum.getkirby.com/t/add-the-same-page-to-a-collection-multiple-times/32146/1)

---

<div class="post-metadata">

**Author:** ![breaddes](https://avatars.discourse-cdn.com/v4/letter/b/e47c2d/32.png) [@breaddes](https://forum.getkirby.com/u/breaddes)\
**Post date:** [October 9, 2024, 9:44am UTC](https://forum.getkirby.com/t/how-to-handle-multi-date-events-as-separate-pages/32635/3 "2024-10-09T09:44:41Z")

</div>

That is very helpful. Is it possible that existing pages are always overwritten if the slug already exists? There should be several events, but I only ever have one:

```auto
$consolidatedEvents = new Pages();

        foreach($events as $event){
            $dates = $event->dates()->toStructure();

            foreach($dates as $date) {
                $eventDate = $date->date()->toDate('Y-m-d');
                $eventTime = $date->time();

                if($eventDate >= date("Y-m-d")) {
                    $event->setEventDate($eventDate);
                    $event->setEventTime($eventTime);
                    $consolidatedEvents->add($event);
                }
            }
        }

```

---

<div class="post-metadata">

**Author:** ![breaddes](https://avatars.discourse-cdn.com/v4/letter/b/e47c2d/32.png) [@breaddes](https://forum.getkirby.com/u/breaddes)\
**Post date:** [October 9, 2024, 10:21am UTC](https://forum.getkirby.com/t/how-to-handle-multi-date-events-as-separate-pages/32635/4 "2024-10-09T10:21:36Z")

</div>

I have found a solution to the problem. This renews the slug.

`$newEvent = $event->clone(['slug' => $newSlug]);`

---

<div class="post-metadata">

**Author:** ![matzebuchholz](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@matzebuchholz](https://forum.getkirby.com/u/matzebuchholz)\
**Post date:** [August 13, 2026, 8:39am UTC](https://forum.getkirby.com/t/how-to-handle-multi-date-events-as-separate-pages/32635/5 "2026-08-13T08:39:16Z")

</div>

Hi breaddes,  
I have a very similar use case and am having trouble making progress. Would it be possible for you to post the complete code (page model and page template) here? That would be a huge help!  
Thanks!
