Hello, I have an acf flexible content field that I am using for my own custom page builder components.
page.blade.php looks like this:
@extends('layouts.app')
@section('content')
@while(have_posts()) @php(the_post())
@include('partials.page-builder', ['pb_data' => $pageBuilder])
@endwhile
@endsection
$pageBuilder is an array of all the data that has been setup and formatted in App.php. In the partials.page-builder file I just have a switch case getting the flexible content layout names and including the correct partial for that module like so:
@foreach($pb_data as $layout)
@switch($layout['module_layout'])
@case('text_module')
@include('partials.module-text', $layout['module_data'])
@break
@case('dual_feature_cards')
@include('partials.module-dual-feature-cards', $layout['module_data'])
@break
...
This all works but when I setup a shortcode that tries to render a view, it duplicates all of the content of the page-builder.blade.php file.
here is my shortcode setup:
add_shortcode('list-group-link', function( $atts, $content = null ) {
// Extract the shortcode attributes
$atts = shortcode_atts( array(
'link' => '#',
'heading' => 'Heading',
'subheading' => 'Subheading',
'cta_text' => 'Learn More',
), $atts );
return view('components.list-group-link', [
'link' => $atts['link'],
'heading' => $atts['heading'],
'subheading' => $atts['subheading'],
'cta_text' => $atts['cta_text'],
] );
});
If anyone has insight as to what is causing this to duplicate the rendering of the entire page builder, it would be greatly appreciated. If I comment out the return view(components.list-group-link...
part of the shortcode and just return a test string everything works fine again.
Thank you