Heya,
I am trying to use kirby for an event calendar. It should be able to deal with more than a thousand events. (once this pandemic is over…)
I have followed the advice to split up the events in a tree-like subfolder structure and went along with some advices I found here in the forum:
.
├── 1_veranstaltungen
│ ├── 2020
│ │ ├── 09
│ │ │ ├── 202009041221_exhibition
│ │ │ │ └── event.txt
│ │ │ └── 202009261400_otherevent
│ │ │ └── event.txt
│ │ ├── 10
│ │ │ └── 202010161900_ausstellung
│ │ │ └── event.txt
│ │ └── 12
│ │ └── 202012030043_test-event-konzert
│ │ └── event.txt
│ ├── _drafts
│ │ └── i-am-a-draft-event
│ │ └── event.txt
│ ├── events.txt
So, the panel users creates a new event directly the main events page, all drafts are in a “general” draft folder and only when the page status changes to ‘listed’ a hook comes along and sorts them into the respective subfolder. And vice versa.
'hooks' => [
'page.changeStatus:after' => function ($newPage, $oldPage) {
$page = $newPage;
if($page->template() == 'event' && $page->status() == 'listed') { /* unlisted status is not used here */
$year = $page->date_start()->toDate('Y');
$month = $page->date_start()->toDate('m');
$newdir = $page->parent()->contentFileDirectory() . '/' . $year . '/' . $month . '/' . $page->dirname() ; /* year/month/subfolder structure */
$olddir = $page->contentFileDirectory();
Dir::move($olddir, $newdir);
}
if($page->template() == 'event' && $page->status() == 'draft') {
$newdir = $page->parent()->parent()->parent()->contentFileDirectory() . '/_drafts/' . $page->dirname() ; /* general drafts folder directly under 1_events */
$olddir = $page->contentFileDirectory();
Dir::move($olddir, $newdir);
}
}
],
I don’t have much experience with routes and altering the panel logic in general in Kirby, and so I would be glad if someone could point me in the right direction with these questions:
- Redirect: How to forward the panel user to the right page after is had been moved?
The current hook, of course, produces a The page cannot be found Error in the panel. But a go($newpage) command doesn’t work in the panel it seems. Any ideas? Couldn’t find a solution in the forum either, but maybe I was looking for the wrong thing.
- Panel View: How to visually hide this tree structure in the panel?
If I don’t want to bother the editors with navigating year+month folder structures, how could I make it this comfortable in the panel? I use the pagetables plugin, but as far as I understood, there is no virtual parent option in general: https://github.com/sylvainjule/kirby-pagetable/issues/54 Could this by filtered somehow?
Any help appreciated very much and in general thanks to this fantastic forum, it helped me already in so many ways!
PS: since the question of performance-related subfolder-structure pops up a few times in the forum, maybe this could also be a potential cookbook?