[solved] Kirby-Builder Plugin: Builder Element into Builder Container

Hello there,

i am very satisfied with the Kirby-Builder, so i can publish any kind of Content Situation i want.
But now i got the Situation, that I have the Builder Elements (for example) “Text-Image Combination”, “RTE” and a “Gallery”, and i want to place this into a Builder Element like a “Container”. This Container Element has two, three or four slots to place the Builder Elements. So the Container wraps the other Elements.

I need to have the Container Builder Element to place the other Kirby-Builder Elements in the same Row as the Container.

I hope i explained it well :frowning:

Is it possible to achieve something like this?

Then you need to nest your elements, which is possible.

And this might be my Problem.
I will place my YAML Content here, so I can describe it better.

Pages/default.yml

title: Default Page
preset: page
options:
  changeTemplate:
    - default
    - story
fields:
  mybuilder:
    label: Page Builder
    type: builder
    columns: 1
    fieldsets:
      basicheadline:
        extends: builder/basicheadline
      basictext:
        extends: builder/basictext
      container2col:
        extends: builder/container2col                        

The Container2Col Builder:

name: Container 2 Col
fields: 
  colleft:
    label: Column left
    width: 1/2
    type: builder
    fieldsets:
      basicheadline:
        extends: builder/basicheadline     
  collright:
    label: Column Right
    width: 1/2
    type: builder
    fieldsets:
      basicheadline:
        extends: builder/basicheadline

Info: I reduced my Code to Basicheadline and Basictext, i have more Builder Elements.

The Output in the Panel is:

Where does this name property come from?

It’s the Container Name “Container 2 Col”

Me again…
i got the nexted Builder in the Panel working. But i can’t see a Code Difference:

name: Container 2 Col

    fields: 
     colleft:
     label: Column left
     width: 1/2
     type: builder
     fieldsets:
      basicheadline:
        extends: builder/basicheadline 
      basictext:
        extends: builder/basictext                      
      colright:
      label: Column right
      width: 1/2
      type: builder
      fieldsets:
        basicheadline:
          extends: builder/basicheadline 
        basictext:
          extends: builder/basictext

What i saw is that “$page->mybuilder()->toBuilderBlocks()” has no Output. When I remove the Function “toBuilderBlocks()” i do see the Content.

Could you provide a more detailed error description, please? And please provide your code, not just that one line.

On a side note: Please always wrap blocks of code within three backticks on a separate line before and after the block. It will instantly become much more readable.

This is my Code in the Page Template:

        foreach($page->mybuilder()->toBuilderBlocks() as $key => $block):
        snippet('blocks/' . $block->_key(), array('data' => $block));
        endforeach;

If i do:

    <?php dump( $page->mybuilder()->toBuilderBlocks()  ); ?>

It generates the following Output in the Page Template:

Kirby\Cms\Structure Object
(
    [0] => 0
    [1] => 1
)

I hope the Code will be displayed correctly now. :confused:

The dump output looks ok to me.

Note that for nested builder fields, you need to apply toBuilderBlocks on the nested field (inside the relevant block snippet).

Note that for nested builder fields, you need to apply toBuilderBlocks on the nested field (inside the relevant block snippet).

Yes, good Mention!
Now it works!

@texnixe i am so happy about your instant Help! Thank you very much.