How to render block preview from MB Builder

Support MB Builder How to render block preview from MB Builder

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #31054
    Matt VMatt V
    Participant

    I'm building some blocks using MB Builder, and I like the process so far.

    Unfortunately, none of my blocks have previews, and I can't quite figure out how to add them within Builder itself.

    I see how to do it in MB Blocks in the docs and in other forum answers. But I don't see a corresponding set of fields in MB Builder. Is there a way to render previews from Builder?

    Thanks for your help.

    #31063
    Long NguyenLong Nguyen
    Moderator

    Hi Matt,

    MB Builder does not support full coding settings. We will try to do it in future updates. For now, please use the code to show the block preview.

    #31065
    Matt VMatt V
    Participant

    Hi Long. Thanks for your help.

    When you say that I should use the code to show the block preview, what is the syntax for that? Is that where I’d use is_preview?

    #31068
    matijamatija
    Participant

    Where do I put the code in MB Builder to show preview?

    #31071
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The variable is_preview lets you know if you’re in the preview mode for Gutenberg or on the front end. It’s useful when you want to display a custom message to users when they edit the block on the back end. See my screenshot https://imgur.com/s295oqk https://imgur.com/r9025Zv

    Get more details here https://docs.metabox.io/extensions/mb-blocks/#render_callback

    If you use the block setting preview, the content will show on the small preview area. Screenshot https://imgur.com/mMB5a5m

    Get more details here https://docs.metabox.io/extensions/mb-blocks/#preview

    #31073
    Matt VMatt V
    Participant

    Thanks, Long. I see how is_preview works now.

    What I hear you saying is that MB Builder does not yet have a way to set the block setting preview, so it is not possible to generate the small preview with Builder. And if that is important enough, we should code the block in MB Blocks instead.

    Did I get that right?

    #31083
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Yes. To use all settings of Meta Box and extensions, I recommend using the code. You can also manage and customize custom blocks the way you want.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.