Closed albeeboy closed 3 years ago
Is there something in wordplate/extended-acf that is preventing this from working?
We can't help you debug your application. All I can say is that we've tested this library with Gutenberg blocks and we know that it works.
Also; it doesn't look like you're using wordplate/extended-acf
. The field group shouldn't be visible in the dashboard.
@albeeboy here is an minimal example for creating a text block with extended-acf and ACF ...
<?php
declare(strict_types=1);
use WordPlate\Acf\Fields\Wysiwyg;
use WordPlate\Acf\Location;
acf_register_block_type([
'name' => 'Text',
'title' => __('Text'),
'description' => __('A text block.'),
'render_template' => get_theme_file_path('includes/acf/blocks/text/template.php'),
'enqueue_style' => get_asset_file_uri('assets/blocks/text.css'),
'post_types' => ['page'],
'category' => 'common',
'icon' => 'editor-textcolor',
'align' => 'wide',
]);
register_extended_field_group([
'title' => 'Text Block',
'fields' => [
Wysiwyg::make('Text')
->instructions('Add the text block content.')
->mediaUpload(false)
->toolbar('text')
->required(),
],
'location' => [
Location::if('block', 'acf/text')
],
]);
ACF Pro is very proud of the fact that you can jump right in and create Gutenberg blocks using field groups. I set it up in a wordplate project, using extended-acf, and following the ACF Pro blocks guide. I've double- and triple- checked it, but I can't get the blocks to render.
Here's what I have:
theme/functions.php
theme/partials/blocks/action-bar/action-bar.php
In the CMS, I added a Block: Action Bar field group with the corresponding inputs:
So far so good. Now if I edit a Page, and add a block, my Action Bar block appears as an option. Beautiful, right? Now I select Action Bar, the ACF fields appear and I can fill them out. So cool! Then I update the edit page and reload the rendered page and...sad trombone...no Gutenberg block. However, in the browser inspector, where the block should appear, the data from the block shows up as commented JSON, like so:
This is where I get stuck. I can't figure out how to get this data to render as the template file. I did a test in a vanilla WordPress ACF Pro instance and the blocks render as expected, easy-peasy. Is there something in wordplate/extended-acf that is preventing this from working? Is it a scoping issue? Not sure where to go from here.