Open julienkos opened 2 years ago
That’s weird. We use custom blocks a lot.
Whats your GQL look like?
Can you also post your PHP for the block registration?
Hi Drew, thank you for the quick reply!
Here is the PHP
acf_register_block_type(array( 'name' => 'hero', 'title' => __('Hero'), 'description' => __('A custom hero block.'), 'render_template' => get_template_directory() . '/template-parts/blocks/hero/hero.php', ));
Turns out this alone doesn't cause the issue. It only starts when I add a field to the block.
I set "Show in GraphQL" to yes and everything else is default. I can make a video to show if you like.
This is what I have on a site that is working great:
<?php
/*
* Register custom ACF blocks
* SEE https://www.advancedcustomfields.com/resources/blocks/
* SEE https://www.advancedcustomfields.com/resources/acf_register_block_type/
*/
function fuxt_custom_blocks() {
// Abort early if custom blocks not supported (not ACF Pro).
if( !function_exists('acf_register_block_type') ) {
return;
}
// Credit block.
acf_register_block_type(array(
'name' => 'credit',
'title' => 'Credit',
'description' => 'A custom credit block.',
'category' => 'text',
'keywords' => array('text', 'credit'),
'icon' => 'editor-textcolor',
'render_template' => get_template_directory() . '/blocks/credit/block.php',
'enqueue_style' => get_template_directory_uri() . '/blocks/credit/block.css',
));
// Scrolling Gallery
acf_register_block_type(array(
'name' => 'scrolling-gallery',
'title' => 'Scrolling Gallery',
'description' => 'A side scrolling gallery block.',
'category' => 'media',
'keywords' => array('gallery', 'scrolling', 'image'),
'icon' => 'images-alt',
'render_template' => get_template_directory() . '/blocks/scrolling-gallery/block.php',
'enqueue_style' => get_template_directory_uri() . '/blocks/scrolling-gallery/block.css',
));
// Stats Block
acf_register_block_type(array(
'name' => 'stats',
'title' => 'Stats',
'description' => 'A block used to show statistics.',
'category' => 'text',
'keywords' => array('statistics', 'numbers', 'count'),
'icon' => 'info',
'render_template' => get_template_directory() . '/blocks/stats/block.php',
'enqueue_style' => get_template_directory_uri() . '/blocks/stats/block.css',
));
// Video Tray
acf_register_block_type(array(
'name' => 'video-tray',
'title' => 'Video Tray',
'description' => 'A block to show multiple small Vimeo videos in a scrolling tray.',
'category' => 'media',
'keywords' => array('video', 'vimeo', 'scrolling'),
'icon' => 'video-alt2',
'render_template' => get_template_directory() . '/blocks/video-tray/block.php',
'enqueue_style' => get_template_directory_uri() . '/blocks/video-tray/block.css',
));
// Press Links
acf_register_block_type(array(
'name' => 'links',
'title' => 'Links',
'description' => 'A block to show multiple links to press articles.',
'category' => 'widgets',
'keywords' => array('press', 'links', 'article'),
'icon' => 'admin-links',
'render_template' => get_template_directory() . '/blocks/links/block.php',
'enqueue_style' => get_template_directory_uri() . '/blocks/links/block.css',
));
// Awards
acf_register_block_type(array(
'name' => 'awards',
'title' => 'Awards',
'description' => 'A block to show Awards.',
'category' => 'widgets',
'keywords' => array('awards', 'links'),
'icon' => 'awards',
'render_template' => get_template_directory() . '/blocks/awards/block.php',
'enqueue_style' => get_template_directory_uri() . '/blocks/awards/block.css',
));
// Video with badge
acf_register_block_type(array(
'name' => 'video-with-badge',
'title' => 'Video with Badge',
'description' => 'A block to to embed a video, with a badge in the top corner.',
'category' => 'media',
'keywords' => array('video', 'badge', 'vimeo'),
'icon' => 'video-alt3',
'render_template' => get_template_directory() . '/blocks/video-with-badge/block.php',
'enqueue_style' => get_template_directory_uri() . '/blocks/video-with-badge/block.css',
));
}
add_action('acf/init', 'fuxt_custom_blocks');
Hi Drew, thank you for the continued support. I tried using some of your code and it works until I add a field to it. I've made a short video showing you what happens.
https://www.loom.com/share/493b4b56cd734e13996ee4c707a28237
I also thought it might be beneficial for me to add a list of my plugins in case you think any of these might be causing issues. I'm not sure which ones you are using along side yours.
I've tried deactivating everything except for the 4 required (your plugin, graphql, acf graphql, and acf pro) but it still causes the same error. Let me know what you think. I will try creating a fresh install and seeing if it happens to me there as well.
any update on this? I'm having the exact same issue.
I can't replicate the same issue on my side. @julienkos @b00y0h Do you still have the issue with the latest version?
Hi there, if you create a custom acf block (gutenberg), no data comes back. I received the following message:
{ "errors": [ { "debugMessage": "get_object_vars(): Argument #1 ($object) must be of type object, array given", "message": "Internal server error", "extensions": { "category": "internal" }, "locations": [ { "line": 5, "column": 7 } ], "path": [ "pages", "nodes", 0, "blocks" ] } ], "data": { "pages": { "nodes": [ { "title": "Home", "blocks": null } ] } }, "extensions": { "debug": [] } }
Any advice on how to fix this issue?
As for steps to reproduce:
I am using the latest version of ACF Pro.