Hey, I’m trying to auto-generate url for new posts just based on the timestamp. I’m using the following blueprint and this helper function (In a plugin).
Helper function, I can see this being printed in the logs when I’m creating a new “Photo” post.
I wanted to show the generated url of the post in the panel…but the way you asked that made me question that. So I just removed it and everything works. I’m guessing it was overwriting the “internal” slug field of the post?
If there a way to still achieve that to display that slug in the panel, I’ve tried something like this but that doesn’t work as that would only be evaluated on creation as far as I understand.
url:
label: URL
type: text
help: "The url of the post."
value: "{{ page.url }}"
Why not use an info field instead of a field that can be modified if it is purely informational? Although, I wonder what additional value there is in viewing a unix timestamp
Why not use an info field instead of a field that can be modified if it is purely informational?
That would be an option, I don’t need to edit it. But what exactly do you mean by a “info” field. Type “info”? But then how would I set the value to be the full url (or just the timestamp, doesn’t really matter).
In the meantime I also found the original documentation that kinda explains why my “slug” field was overwriting the Kirby one, I shouldn’t have used a reserved word (“Do not use names that are reserved by native page methods”, Using fields | Kirby CMS).
info:
type: info
text: "The slug of this page is {{page.slug}}"
Well, yes, using reserved field names is a bit problematic.
But the reason the field stayed empty was because you did not fill it with either a default value at page creation or in an page.create:after hook. Similar with your second attempt with the url field, you used a property named value that does not exist. But having said that, the default property for most fields doesn’t support query language, so using the correct property wouldn’t have helped in this case.