Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

(Solved) Extend custom page creation modal

Solved by Paul Massendari View solution

Started by Soulrain 9 years ago · 3 replies · 972 views
9 years ago

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.

9 years ago Solution

Greetings!

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.

YAML
title: Item
'@extends':
    type: default
    context: blueprints://pages

form:
  fields:
    tabs:
      fields:
        options:
          fields:
            publishing:
              fields:
                header.published:
                  default: 0

Hope it helps!

👍 2
9 years ago

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!

9 years ago

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).

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1135 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 60 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 132 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 108 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 127 7 months ago