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?