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

Extending blueprints

Started by Muut Archive 9 years ago · 5 replies · 599 views
9 years ago

Hello,

I try to add some configuration options to site.yaml. and to organize them.

Thanks to this page :
https://learn.getgrav.org/forms/blueprints/example-config-blueprints
I was able to do that :

YAML
@extends:
    '@parent'

form:
    fields:
        socials:
            type: section
            title: Réseaux sociaux
            underline: true
            fields:
              facebook:
                  type: text
                  label: Facebook
                  size: large
              youtube:
                  type: text
                  label: Youtube
                  size: large 

Wich output

YAML
facebook: ''
youtube: ''

My desired output is :

YAML
socials :
    facebook: ''
    youtube: ''

So I could access them via {{config.site.socials.facebook}} and not {{config.site.facebook}}

Could anyone give me a hint ? :)

9 years ago

Hi,
I think you just need to add socialsas an additional level before facebooketc. because the type sectionis a purely visual grouping in the admin.
So, if you do:

YAML
form:
    fields:
        socials:
            type: section
            title: Réseaux sociaux
            underline: true
            fields:
               socials:
                 facebook:
                    type: text
                    label: Facebook
                    size: large
                 youtube:
                    type: text
                    label: Youtube
                    size: large 

you should be good to go ;)

9 years ago

Thank you for your time.

I tried, but then, in the admin panel my new fields won't show up.
I have the title of the section, but no fields.
Admin panel without fields

9 years ago

Hmm, you're right, this does not work for me too...
What works for me is:

YAML
form:
    fields:
        socials:
            type: section
            title: Réseaux sociaux
            underline: true
            fields:
               socials.facebook:
                  type: text
                  label: Facebook
                  size: large
               socials.youtube:
                  type: text
                  label: Youtube
                  size: large
9 years ago

Oh great, that's perfect !
This way I'll be able to keep a comprehensible structure.

Thank you very much. :)

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1323 9 years ago
Archive · by Muut Archive, 9 years ago
2 919 9 years ago
Archive · by Muut Archive, 9 years ago
2 4048 9 years ago
Archive · by Muut Archive, 9 years ago
1 2923 9 years ago
Archive · by Muut Archive, 9 years ago
3 1106 9 years ago