you could just check your date field and use the move page command… it’s actually a few lines of code, so it doesn’t need to be a full fledged plugin… you could use it within site/plugins/ to call it every time a page is accessed though.
should the page still be available at the old URL? If not, then you can simply move the page, e.g. using a cron job every night. Moving a page only when it is accessed is not very reliable.
if yes, you could move the page but use a route to make it available at the old URL
but: You might end up with the wrong content under the same URL if a user creates a new page with the same UID in the posts folder
So the question is: why do you need an archives page in the form of a new folder?
I’d use a filter to only show current articles in the frontend. And if you want to create an archives page, you can do that using a route or with a new folder (and then also filter posts by date), but without actually moving the posts into that folder.
move() does not move the page to a new directory, you can only change the UID. You would have to use the file methods](https://getkirby.com/docs/toolkit/api#) from the toolkit, in particular f::move(). But what about the questions I asked above?
instead of hardcoding find(“events”) … let’s say you have multiple access towards your event.list (parent template of whereever your events are children of) you’d need to change several files manually.
but obviously this would only work if you are using the event.list template once.
Sure, however I tend to use snippets and pass the desired
root page through as a snippet variable. I stripped this out above for brevity. That way you can use the same snippet with a news section for example.
I would love to turn my solution into a plugin because it’s pretty cool and includes support for Google calendar events alongside Kirby articles, and uses jQuery fullcalendar.js to show events on a visual calendar, but my PHP is pretty young because I’m learning it and I don’t know how to make a plugin. I know there are docs for that. I guess I could set it up on starter kit and open it up to the community for refinement via github.
I would not move any page for this purpose, but build new events within the directory for old events.
Then I would build your logic in the blueprints, snippets and templates as needed, e.g. look at the homepage of the Kirby starterkit. There you find the “Latest Projects”, their content is saved as pages in the projects directory.
I see no need to move pages, if you design the content directory of your website like you would do this with the data of all pages if you use a database. Then you can get the data of the new events on every webpage you want (e.g. on a “New events page”).
Thank you for the link to f::move(). I’ll use dir::move($old, $new) in my case.
Could someone provide an example for the old and new path that move accepts? I can’t get it to work. I also experimented with is_dir(), but can’t figure out where the root is, nor how I can get to /content/events/…