February 16, 2023, 11:07pm
Hi Kirby Community,
so I have this idea of
creating my own simple journal with kirby since I like the simplicity of the panel and the fact, that my journal entries will be stored in plain text files on my own server.
I already tried to realize this project a few years ago but I got stuck, since I found no simple way to set the current date as page name when creating a new page.
My question is: are you aware of any plugin, that adds such a functionality. If not: what would be the best approach to realize this?
My first idea would be to work with hooks, to set the page name automatically. For example the
Did anyone already use Kirby for journaling? Thank you for any hint!
February 16, 2023, 11:59pm
You can use this plugin:
GitHub - steirico/kirby-plugin-custom-add-fields: Custom fields for Kirby's add dialog.
Or you create a page model that overwrites the static
create() page method
February 17, 2023, 12:16am
I think the hook method is the easiest, though you might want to use
I went the same route using
page.update:after to add a custom “updated date” field with associated logic to my blog posts, because I don’t want to rely on the filesystem’s modified date as it’s brittle and I might want to make minor corrections (spelling etc.) without incrementing the date.
It’s really easy, just make a single file plugin with a few lines of code and you’re golden.
February 17, 2023, 7:21am
You can’t do this in a before hook.
When you change the slug (and I’m assuming this also refers to the slug) in an after hook, then you will get an error with the current route.
February 17, 2023, 7:35am
I’m assuming OP would just use the hook to populate the title field with the current date.
The slug is formed using the title so you’re just leverage what’s already there instead of trying to hack into the slug generation process.
February 17, 2023, 12:04pm
Nevertheless, it is not correct that you can do this in a before hook, that was my main point.
And also, I don’t think you want to insert some title at page creation just to overwrite it with the date in a hook, in that case, you better insert the date right from the start.
If it is about the title, it would still be better to do this in a model rather than a hook.
@ammon Could you please clarify your exact requirements. If you don’t want to fill in a title, the plugin I referred to above is your best bet.
February 17, 2023, 2:09pm
After reading further, I understand what you mean now.
February 17, 2023, 2:38pm
Thank you both for your answers, they were already really helpful!
My requirement is exactly what the plugin seems to do. It would be ideal if I had a date field when creating the page – and set the slug accordingly.
I’m looking forward, trying this out! Thanks a lot!