Hi,
I have a problem with block rendering.
I use the connection: ACF + Timber + Gutenberg.
Creating blocks on localhost was not a problem, everything was displayed both on the wp-admin side and on the frontend side (created on Linux, PHP 7.219, nginx)
After installing for test on Windows + the latest XAMPP (PHP 7.39, apache) , it turned out that the blocks do not render (they can not be seen both on the wp-admin and the frontend site).
That’s why I put it on Raspberri Pi (PHP 7.120, apache) and it started normally. I thought maybe it was a matter of Windows and some server settings. However, when installed on a normal web server (Linux, PHP 7.0.33, apache) also did not work.
Does anyone have an idea what could be the reason for the blocks not being rendered?
—-
In the following function does not enter callback at all (text_block_render_callback), however register block works.
add_action('acf/init', 'register_block_text');
function register_block_text() {
acf_register_block(array(
'name' => 'text',
'title' => ('Tekst', 'pep'),
'description' => ('Moduł zwykłego tekstu', 'pep'),
'render_callback' => 'text_block_render_callback',
'category' => 'impresspro-blocks',
'icon' => 'edit',
'keywords' => array('blog'),
'mode' => 'edit',
'enqueue_assets' => function() {
wp_enqueue_style( 'block-text', get_stylesheet_directory_uri() . '/dist/blocks/text/text.css');
}
));
}
function text_block_render_callback($block, $content = '', $is_preview = false)
{
$context = Timber::context();
$context['block'] = $block;
$context['fields'] = get_fields();
$context['is_preview'] = $is_preview;
Timber::render(TEMPLATEPATH . '/views/blocks/text/text.twig', $context);
}
—
WORKING – SAME CODE
—
NOT WORKING – SAME CODE