Greetings and salutations.
I’m using the basic blueprint mentioned here for adding a new page/post and it works as it should.
But I was wondering if it’s possible to add some more options to it. For example, how to make a setting so that the new page/post won’t be published by default and another one to prefill the appropriate fields with some category names and/or tags?
It may be simple and easy or not possible at all but I’m trying to learn so I can help my fellow authors, so please forgive my ignorance and thank you.
What you want to achieve, as far as I know, is done through the blueprint itself, and not on the creation modal, even if you overrided it.
You have to extend and match the structure of the blueprint inside system/blueprints/pages/default.yaml
For your example, you would have to use this blueprint for your template:
Note the default value added for header.published.
Hope it helps!
It does indeed help!
I created a new default.yaml blueprint in /user/blueprints/pages with the content you suggested and now, on every new post, the “Published” field is activated and marked as “No”.
Besides that, your reply pointed me to the right direction so I can search and try to extend the options even more. Some people will be really happy thanks to you. Thank you very much for your help!
Yes, if you add the snippet I posted in a file named default.yaml it will be used by all your other template, because in most case, all blueprints extends default.yaml.
As you have a default.yaml in your theme blueprints folder (user/themes/yourtheme/blueprints) Grav wil pick this one, and this one extends default.yaml which is in system/blueprints/pages/default.yaml.
However, if you name your file with another name, such as blog_post.yaml (for the blog_post.html.twig template) the published override should only apply to pages that use this template (and this blueprint).