kirby-deprecated-plugins / kirby-blueprint-reader

Kirby Blueprint Reader for Kirby CMS
MIT License
13 stars 1 forks source link

kirby builder support for extends #14

Open bnomei opened 6 years ago

bnomei commented 6 years ago

i must agree maybe stacking 4 levels of global field defs onto other is not a great idea but it's DRY, right? another problem might be fieldsets yaml section needed for kirby builder.

page.yml with kirby builder (via extend)

...
fields:
  builder: builder
...

fields/builder.yml defining kirby builder fieldsets (via extends again)

...
label: Builder
type: builder
fieldsets:
  # using 'extends' is required. will not work otherwise. 
  # see https://github.com/TimOetting/kirby-builder/issues/8
  fancyblock:
    extends: fancyblock
...

fields/fancyblock.yml defining a single kirby builder fieldset fields (via extends again)

...
label: Fancyblock
snippet: blocks/fancyblock
fields:
  text:
    label: Text
    type: textarea
  colsize: colsize # finally the last extend
...

fields/colsize.yml final extend step

label: Spaltenbreite
type: select
default: 'w-full'
options:
  w-full: 100%
  w-3_4: 75%
  w-2_3: 66%
  w-1_2: 50%
  w-1_3: 33%
  w-1_4: 25%

in any template

print_r(b::blueprint('page', 'fields/builder/fieldsets/fancyblock')); 
// Array ( [extends] => fancyblock ), but not extended! 

echo b::blueprint('page', 'fields/builder/fieldsets/fancyblock/fields/colsize/options/'.$data->myfield()); 
// this is what i actually want but does not work
jenstornell commented 6 years ago

I'm not sure but I think my plugin only supports one level of global field definitions right now. But because it seems to be possible to have them nested, it should be implemented at some point in the future here as well.