How to set a new default frontmatter on Admin plugin

The title speak for itself. I wrote my articles on raw markdown until now, but I’m tired to copy-paste everytime the frontmatter from the previous pages, editing that and so on. So I want to make admin plugin work for me. I can write the articles on the platform (it’s comfortable, really) but the copy-paste problem stay.
I’ve search online, on the forum, on the documentation, but I still don’t know how to automatize this process.

I presume you would like to set some defaults to Page fields in the Admin plugin when adding a new page to your blog?

Maybe the docs on Example: Page Blueprints and Advanced Blueprint Features might give you some direction.

After extending a blueprint you can assign defaults to the existing fields and/or add your own custom fields with defaults. These defaults can even be set by functions in your theme or plugin (Using Function Calls).

Hope this helps…

PS. This suggestions is decaffeinated…

1 Like

Thanks for the tips: I was just trying to get a default frontmatter in expert mode, but if I can totally reset the form in the classical mode I’m ok too.

When you edit a page in ‘Expert’ mode, there is no blueprint, you just edit the frontmatter manually.

You can ‘extend’ an existing blueprint and add fields to tabs, you can override fields and you can add your own tab with your required fields. And you can create a completely custom form.

The following example is taken from the First Example from the ‘Example: Page Blueprints’ docs. This example allows you to create a dedicated tab ‘Gallery’ in the Page editor in Admin containing your custom defined fields.

  • Create a file ‘/user/blueprints/pages/default.yaml’
  • Copy the following blueprint definition into the created file:
    title: Gallery
    '@extends':
        type: default
        context: blueprints://pages
    
    form:
      fields:
        tabs:
          type: tabs
          active: 1
    
          fields:
            gallery:
              type: tab
              title: Gallery
    
              fields:
                header.an_example_text_field:
                  type: text
                  label: Add a number
                  default: 5
                  validate:
                    required: true
                    type: int
    
                header.an_example_select_box:
                  type: select
                  label: Select one of the following
                  default: one
                  options:
                    one: One
                    two: Two
                    three: Three
    
  • On saving the page, the following frontmatter will be generated:
    an_example_text_field: 5
    an_example_select_box: one
    

Hi,
I had too many things to do in this first times of october, but I tried to pursue the way you pointed at and I surely was able to solve the problem even better than if I followed my first idea. Infact, to set a new default frontmatter you can set a series of settings in the blueprint wich are “text”-type and with a default value.
But that’s the ugly way. With blueprints I even set some options with validation (of urls, for example) and with the classical switch yes/no.
So blueprints are very useful, I’m surprised I originally missed those in the documentation.
Thanks for the advice,
Cheers