Tutorial: Global field definitions aka blueprint snippets

Hi People,

Is there a small tutorial for the noobs :wink: Or can we (uhm well not me) write one?

How to use the Global field option.

Step 1) add the folder site/blueprints/fields
Step2) made it to step one so far.

Need some help. For example how to (re)use it in your blueprint, and how to set up the yml file.

This is the basic way of doing it:

  1. Create the folder site/blueprints/fields.
  2. Create a field definition, e.g. a date field in date.yml
# /site/blueprints/fields/date.yml
label: Date
type: date
default: now

or an image select field in imageselect.yml

# /site/blueprints/fields/imageselect.yml
label: Select an image
type: select
options: images
  1. Reference the snippet in your blueprint, e.g.
# /site/blueprints/mypage.yml
    label: Title
    type: text
  date: date
  myimage: imageselect

Or if you want to give your fields another label or change the default, you can extend it like this:

# /site/blueprints/mypage.yml
    label: Title
    type: text
    extends: date
    label: Published
    default: false
   extends: imageselect
   label: Cover Image

Tnx a lot! I just misunderstood the way to call them. This is great!

Are my blueprints supposed to be yaml files? Mine are PHP?

hi, no only your so called blueprint snippets need te be .yml

Blueprints can be both, PHP and YAML, since Kirby 2.2. So no problems here :smile:

1 Like

o yes I am sorry! haha!

I think I’d rather make my blueprints YAML because it can get tricky having so many php files with exactly the same name open in Coda.

How can i extends multiple fields instead of single like that: fields/meta.php

		label: Meta Headings
		type: headline
		label: Meta Title
		type:  text
		label: Meta Description
		type:  textarea
		label: Meta Keywords
		type:  tags
1 Like

@byybora I don’t think this is available. I’ve tried this, too, but couldn’t get it working.

It would be a nice feature to have, however overriding a single field may be difficult.

@jevets i tried too but couldnt achive :slight_smile:

It doesn’t seem to be possible to create a global field definition for a group of fields (e.g. 1 file that defines multiple fields). I understand extending a group would be akward/not possible, but i’m not interested in extending it. The power to add to the global group or make edits to the group which would then be reflected for every blueprint that calls it would be very useful.

Is it possible to define multiple fields in one global field definition file?

I tried and it doesn’t seem to be, but I’m not going to rule out that I did something wrong. I’d like to confirm this with the pros here.

This has been requested before, check out this post: Blueprint groups


Well, since Kirby now has global field definitions, that makes it even easier to include those and even extend them in your blueprints, even if you use the .yml extension instead of .php.

1 Like

These are great, but I currently miss the option to include groups of fields… not a big issue tho :slight_smile:

I also appreciate the global fields and at the same time see a use for global groups of fields. Would this be hard to implement?