From a0b8cbd9f22728e0346152923c8d523d5977c0c1 Mon Sep 17 00:00:00 2001 From: Zync Date: Fri, 19 Jul 2024 22:54:01 +1000 Subject: [PATCH 1/2] Use relative url for block loading On Windows using the block path will result in the directory separator getting messed up and now loading the acf block correctly. This will fix that and should work for mac too, But i don't have a mac to test with. --- theme/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/theme/functions.php b/theme/functions.php index 3d1cbe6..789145b 100644 --- a/theme/functions.php +++ b/theme/functions.php @@ -73,7 +73,7 @@ public function enqueue_assets() { $dist_uri = get_template_directory_uri() . '/assets/dist'; $dist_path = get_template_directory() . '/assets/dist'; $manifest = null; - + if ( file_exists( $dist_path . '/.vite/manifest.json' ) ) { $manifest = json_decode( file_get_contents( $dist_path . '/.vite/manifest.json' ), true ); } @@ -148,7 +148,7 @@ function acf_block_render_callback( $block, $content ) { $context['post'] = Timber::get_post(); $context['block'] = $block; $context['fields'] = get_fields(); - $template = $block['path'] . '/index.twig'; + $template = 'blocks/'. explode( '/', $block['name'] )[1] . '/index.twig'; Timber::render( $template, $context ); } From 72995528e571dd6eaa13d82a935be2f0466a1a39 Mon Sep 17 00:00:00 2001 From: Zync Date: Fri, 19 Jul 2024 23:03:21 +1000 Subject: [PATCH 2/2] make more readable --- theme/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/theme/functions.php b/theme/functions.php index 789145b..686773b 100644 --- a/theme/functions.php +++ b/theme/functions.php @@ -148,7 +148,8 @@ function acf_block_render_callback( $block, $content ) { $context['post'] = Timber::get_post(); $context['block'] = $block; $context['fields'] = get_fields(); - $template = 'blocks/'. explode( '/', $block['name'] )[1] . '/index.twig'; + $block_name = explode( '/', $block['name'] )[1]; + $template = 'blocks/'. $block_name . '/index.twig'; Timber::render( $template, $context ); }