TimOetting / kirby-v3-builder

17 stars 2 forks source link

No Tabs Structure in page.txt #6

Closed tobiasfabian closed 5 years ago

tobiasfabian commented 6 years ago

Currently the structure of the tabs is saved into the page.txt

page.yml

type: builder
fieldsets:
  test:
    tabs:
      tab-1:
        label: Tab 1
        fields:
          text-1:
            label: Text
            type: text
      tab-2:
        label: Tab 2
        fields:
          text-2:
            label: Text 2
            type: text

page.txt

- 
  _key: test
  tab-1:
    text-1: Lorem
  tab-2:
    text-2: Ipsum

I would prefer a flatter structure for the page.txt to separate Panel layout and content. This would allow the admin to remove, add or change tabs after content is already saved.

- 
  _key: test
  text-1: Lorem
  text-2: Ipsum
TimOetting commented 6 years ago

yeah, I thought about that and ended up leaving the tab structure in the page's yaml. If you would have the fields flat like you suggested, you would have problems if fields in different tabs would have the same name. Maybe it would be a solution to detect duplicate names and hint the user inside the panel. However, this could get pretty confusing when you start extending entire tabs from different yaml files.

tobiasfabian commented 6 years ago

Yes, but:

Kirby doesn’t save the blueprint tabs structure into the .txt. There is the same problem with fields having the same name. You, as a web developer just have to make sure that every field has a unique name. I think that’s acceptable.

Imagine you build a page with the Page Builder – without tabs. At some time in the future you need three more fields in one fieldset. Now it would be more comfortable for the Editor to have tabs. This would be quite difficult to implement, because if you add tabs the Content structure of the txt files won’t fit anymore.

I would prefer a more strict separation of Panel layout and content structure.

TimOetting commented 5 years ago

Hey @tobiasfabian,

I just pushed an update that implements your suggestions of a flat content structure that is not affected by tabs.