I’m creating something like a page builder with ACF. I’m using blade components and they all work all over the website, except in one place, and that is, in the ‘views’ folder, in a custom folder I created named ‘blocks’.
The files get called while looping over with ACF, like so:
<?php
// $flexibleContentPath = dirname(__FILE__) . '\\blocks\\';
$flexibleContentPath = "C:\\Users\\44775\\Desktop\\Web Development\\Clients\\KayLittlehales\\FutureproofED\\wp-content\\themes\\kayTheme\\resources\\views\\blocks\\";
$count = 0;
?>
@if ( have_rows( 'flexible_content' ) )
@while ( have_rows( 'flexible_content' ) ) <?php the_row(); ?>
@if ( have_rows( 'row' ) )
@while ( have_rows( 'row' ) ) <?php the_row(); ?>
<x-section bgColor="{{ $page[$count]['backgroundColor'] }}">
@if ( have_rows( 'column' ) )
@while ( have_rows( 'column' ) ) <?php the_row(); ?>
<div class="{{ $page[$count]['columnWidth'] }}">
<?php
$layout = get_row_layout();
// print_r($page[$count]);
$file = ( $flexibleContentPath . str_replace( '_', '-', $layout) . '.blade.php' );
if ( file_exists( $file ) ) {
@include( $file );
}
?>
</div>
@endwhile
@endif
</x-section>
@endwhile
@endif
<?php $count++; ?>
@endwhile
@endif
@endsection
The issue I face, is that blade components, that are being @include( $file );
don’t compile, although everything works, and the components, as seen on the page such as x-section works.
I can’t seem a way to figure out a way to compile the files. For example, in blocks/blocks-hero.blade.php I have this code:
<x-button variant="primary" kind="solid">button</x-button>
And it doesn’t work, however, it does work on every other page.
The browser literlly shows this: <x-button variant="primary" kind="solid">button</x-button>
in the HTML. While on other pages it shows the code compiled.
I have no idea how to solve this. Tried a hundred things and nothing.