ACF Blocks broken for me. Simple fix required?

This is the generated code I see for an ACF test block:

/* Creating Editor Blocks with ACF PRO */

function test_blocks_acf_blocks_init() {

    // Check if ACF PRO function exists.
    if( function_exists('acf_register_block_type') ) :

        // Register blocks. Don't edit anything between the following comments.
        /* Pinegrow generated Register Blocks Begin */

        acf_register_block_type( array(
            'name' => 'test-blocks/acf-block-test',
            'title' => __( 'ACF Blocks Test #1', 'test_blocks' ),
            'icon' => 'smiley',
            'category' => 'custom-posts',
            'render_template' => 'blocks/acf-block-test/acf-block-test.php',
            'supports' => array('color' => array('background' => true,'text' => true,'gradients' => true,'link' => true,),'typography' => array('fontSize' => true,),'anchor' => true,'align' => true,'multiple' => false,'className' => false,),
            'base_url' => test_blocks_plugin_base_url(),
            'base_path' => test_blocks_plugin_base_path()
        ) );

    /* Pinegrow generated Register Blocks End */

…and ACF Blocks do not work for me at all in my local installation. I have played around endlessly with the block settings, but everything looks fine (in terms of previewing the PHP and manually checking the file path in the generated plugin) whilst the HTML does not render in the backend editor nor the frontend.

My assumption was the render template is the likely cause, so I changed this line in the plugin code generated by Pinegrow:

'render_template' => plugin_dir_path(__FILE__) . 'blocks/acf-block-test/acf-block-test.php',

Which is in line with what I’ve used previously when working with ACF Blocks.

Immediately, no more issues. The block renders perfectly in Gutenberg and the frontend.

This is a very pressing issue for me. I’d greatly appreciate either a quick fix pushed out or someone explaining what I’m doing wrong for this to be required currently on my end.

Edit: adding this info as requested in the sticky thread:

  • Which Operating System and version of the Operating system? macOS Ventura 13.5.2
  • Running Pinegrow directly on the host system or in a Virtual Machine? Host system
  • Pinegrow version number: 7.71
  • Hardware details: M1 Pro 16" MacBook Pro, 32GB memory, 1TB storage
  • Do you have a Firewall and/or Anti Virus running in the background? Only whatever is default for macOS
  • Do you have a Webserver running in the background? Local by Flywheel, otherwise nothing

This might make more sense as a solution. The templates also work fine if this is the render template:

'render_template' => test_blocks_plugin_base_path() . '/blocks/acf-block-test/acf-block-test.php',

So it could be that Pinegrow is not formatting the render template in a usable way. I.e. the path needs to be complete, and an opening “/” needs to be added to the front of the relative path bit. It is not there by default if you look at the OP.

1 Like

Thanks @Bryn! I added the path prefix to the render_template for ACF blocks. This will be out in the next release.


Much appreciated @matjaz!

Don’t forget that plugin_dir_path(__FILE__) works as a standalone prefix for the render template path currently provided, and that test_blocks_plugin_base_path() only works if a / exists at the start of /blocks/block-name/whatever.

1 Like

@Bryn the update is now out. Please check it out and let me know if everything is ok: Pinegrow Web Editor 7.7, 7.71 & 7.72- September 14, 2023 | Pinegrow Web Editor

1 Like

Looks to be working now @matjaz. Thanks!

1 Like