Support

Account

Home Forums Gutenberg ACF 6 + Blocks + Timber : render_callback and block.json

Solving

ACF 6 + Blocks + Timber : render_callback and block.json

  • Build:
    – Timber Library (mu-plugin)
    – ACF Pro 6.x (mu-plugin)
    – ACF Blocks
    – Render via 'render_callback' instead of 'renderTemplate'
    – Timber (Gutenberg) Blocks

    There’s another thread over at https://support.advancedcustomfields.com/forums/topic/register-block-preview-image-with-acf_register_block_type/#post-146180 which allows support using the acf_register_block_type() function for a generic image.

    In pre-6.x, this approach was working perfectly to just display a preview image (instead of prepopulating content via ajax, which never really worked).

    After converting my block to block.json, still using the same custom render_callback, I can’t seem to get it to load the preview.

    I tested with a bit of poor-person’s debugging and its not loading the custom render_callback at all and just ‘spins’ the loading icon while dropping an error via Uncaught TypeError: n.jsx is undefined from acf-pro-blocks.min.js?ver=6.0.2.

    —-

    Am I approaching it wrong? I’m trying to avoid using a specific RenderTemplate because TWIG/Timber IS renders the templates itself. Our current setup ‘scans’ each directory in blocks/, grabs the associated PHP file, and loads the register_block_xx function from there, so I am really hoping the solution does not require one PHP file as the “plugin” and another as the “template”.

    6.x incompatibility with the existing Timber instructions of leveraging the custom render_callback? (See https://timber.github.io/docs/guides/gutenberg/#how-to-use-acf-blocks-with-timber )

    —–

    Not really a bug, per say, since its literally stacking Timber on top of Gutenberg on top of ACF, but it WAS working. Thus, the open question! ^-^ (Also not really sending as a bug, to give reference for other Timber developers! ^-^ )

  • What is your filename for the json.

    After much messing about through the ACF forums I found out that my blocks.json file was failing to load because the block json requires them to end in block singular ( i.e. block.json or file-block.json etc )

  • Yeah, that exact filename is also needed , but that was correct. Perhaps I did not build properly at the time. However, in the end I decided to go full ReactJS/ Blocks and leave out ACF for this block. And that works now. Thanks for the feedback though @tjhole-support !

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.