[Sage 10] Blade does not compile while in the 'while loop'

I am using ACF PRO, with Flexible Content.

I’m building components/blocks that the user can select and give them some properties, such as change the background color for the section.

Now, the values get passed, and all works, the blade component I’ve created works, however, there’s one issue.

It does not compile in the page.blade.php. This is the code:

@extends('layouts.app')

<!-- @section('content') -->

<h1>Page</h1>

<?php

// $flexibleContentPath = dirname(__FILE__) . '\\blocks\\';

$flexibleContentPath = "C:\\Users\\44775\\Desktop\\Web Development\\Clients\\KayLittlehales\\FutureproofED\\wp-content\\themes\\kayTheme\\resources\\views\\blocks\\";

$bgColor;

if ( have_rows( 'flexible_content' ) ) :

    while ( have_rows( 'flexible_content' ) ) : the_row(); ?>

   

   <?php if ( have_rows( 'row_config' ) ) :

         while ( have_rows( 'row_config' ) ) : the_row(); ?>

            <?php if ( get_sub_field( 'background_color' ) ) : ?>

                

                <?php $bgColor =  get_sub_field( 'background_color' )[0]; ?>

                

            <?php endif; ?>

    

        <?php endwhile; ?>

    <?php endif; ?>

 

    <?php if ( have_rows( 'row' ) ) :

            while ( have_rows( 'row' ) ) : the_row(); ?>

 

            <x-section bgColor=<?php echo $bgColor; ?>>

            <!-- <x-section> -->

                <?php if ( have_rows( 'column' ) ) :

                    while ( have_rows( 'column' ) ) : the_row(); ?>

                    <div>

                        <?php $layout = get_row_layout();

                        $file = ( $flexibleContentPath . str_replace( '_', '-', $layout) . '.php' );                        

                        

                        if ( file_exists( $file ) ) {

                            include( $file );

                        }

                        ?>

                    

                    </div>

                    <?php

                    endwhile;

                endif; 

                ?>

            </x-section>

                

                <?php

            endwhile;

        endif;

    endwhile;

endif;

?>

<x-section bgColor="teritary">

    OUTSIDE THE LOOPS ETC 

    </x-section>

The issue with this is, whatever is inside the while loop, the blade doesn’t compile. This is how HTML in browser looks like:

<x-section bgColor="primary">

While the last one, outside the loop, compiled correctly

<section class="bg-teritary-default">

I am not sure how to solve this, any help would be appriciated :slight_smile:

This topic was automatically closed after 42 days. New replies are no longer allowed.