Panel view of builder modules

Hello there

as we are using the builder plugin to place a lot of content variations i want to improve the panel for the author.
How would you create the panel view of the placed builder.

For example:
I am placing a builder called “text-image combination”, in the code i am checking if the image is set, if not i am returning, because the image is essential for the frontend view. But in the Backend / Panel the view should be different. Maybe showing the Text, a few chosen options and the author can see “no image selected”.

How would you do that? I am curious about the “best practice” method.

Thank you

The builder allows you to set snippets that define how each entry looks (using the snippet option in your blueprint). These snippets can be independent from the snippets you use in the frontend.

So you mean i can set a frontend rendering snippet and one for the panel?
If yes, how?! :slight_smile:

The builder has a snippet option:

For example:

article_builder:
    label: Artikel Building Blocks
    type: builder
    fieldsets:
      bodytext:
        label: Text field
        snippet: builder/bodytext_panel
        fields:
          text:
            label: Text
            type: simplemde

In the frontend a snippet with the same name as the field is used, in this case bodytext.

Sorry to ask you again, i am a bit confused.
For example here you see a builder snippet we use:

        textimage:
      label: Text/Bild Kombination
      snippet: sections/textimage
      fields:
        image:
          label: Bild
          type: image
        text:
          label: Text
          type: markdown
        orientation:
          label: Ausrichtung
          type: select
          default: 1
          options:
            1: Bild links - Text rechts
            2: Bild rechts - Text links
        popup:
          label: Bild per Klick vergrößern
          type: checkbox
          text: ja

This Code is used to have a frontend Snippet called textimage.php in sections. But where do i declare a backendsnippet?

In the snippet option, see above.

The snippet option is only for the backend, not the frontend, see the readme of the plugin. It is an alternative to the entry option of a native structure field.

In your template you loop through the building blocks and the plugin uses the name of the fieldset to render the module. The fieldset is named after the name of the field.

Aaaah okay… so i can declare a snippet to each “field” i am using in my builder module.

Exactly (and some more chars).

1 Like

@texnixe thank you, that helped me!

You can also store these panel snippets in a separate subfolder of the snippets folder if you want. Just make sure to add the correct path to the snippet.

Yes, that was my plan so i just have a few for images, bodytext and so on. I want to organize the panel a bit, so i will do that as well.