In my controller, I have the following simple method, which when I do a var_dump, shows me all the ACF elements within the array
class TemplateMission extends Controller
{
protected $acf = true;
public $test;
public function mission() {
if (have_rows('all-flex-fields-mission')):
while(have_rows('all-flex-fields-mission')): the_row();
$left_hand_content = get_sub_field('left-hand-content');
var_dump($left_hand_content);
endwhile;
endif;
}
use Partials\FlexibleLayout;
}
The array that is dumped looks like the following:
array (size=1)
0 =>
array (size=5)
'acf_fc_layout' => string 'content' (length=7)
'content-icon' =>
array (size=24)
'ID' => int 10846
'id' => int 10846
'title' => string 'champion' (length=8)
'filename' => string 'champion.png' (length=12)
'filesize' => int 10666
'url' => string 'http://dev.xyz.local/wp-content/uploads/2020/08/champion.png' (length=60)
'link' => string 'http://dev.xyz.local/mission-test/champion/' (length=43)
'alt' => string '' (length=0)
'author' => string '10' (length=2)
'description' => string '' (length=0)
'caption' => string '' (length=0)
'name' => string 'champion' (length=8)
'status' => string 'inherit' (length=7)
'uploaded_to' => int 10828
'date' => string '2020-08-07 16:26:16' (length=19)
'modified' => string '2020-08-07 16:26:16' (length=19)
'menu_order' => int 0
'mime_type' => string 'image/png' (length=9)
'type' => string 'image' (length=5)
'subtype' => string 'png' (length=3)
'icon' => string 'http://dev.xyz.local/wp-includes/images/media/default.png' (length=57)
'width' => int 41
'height' => int 48
'sizes' =>
array (size=18)
...
'content-title' => string 'CHAMPION FOR CONSUMERS' (length=22)
'content-subtitle' => string 'Developing a Better Way to Shop for' (length=45)
'wysiwyg' => string '<p>We want to make finding the best broadband as easy as possible, so we build tools to help consumers do just that.</p>
<p>But, that’s just the start.</p>
<p>At our core we are champions for the consumer.</p>
<p>To us this means:</p>
<ul>
<li>Bringing transparency in government data and research.</li>
<li>Aggregating IP verified customer reviews and ratings.</li>
<li>Fostering competition through better awareness of local providers.</li>
</ul>
'
Which matches what I have in the Pages
In my template page, I have the following:
@while(have_rows('left-hand-content')) @php(the_row())
@php($content_icon= get_sub_field('content-icon'))
@php
echo 'makes it here';
@endphp
@if($content_icon)
<div>
{!! $content_icon !!}
</div>
@endif
@endwhile
How is it possible that I have access to the entire array, but I cannot display a single item?
I have also tried the following to just loop through the get_row_layout:
@if(TemplateMission::mission())
@while(have_rows('left-hand-content')) @php(the_row())
@php echo 'gets here'; @endphp
@php $fieldname = get_row_layout() @endphp
@php echo $fieldname; @endphp
@endwhile
@endif
I have tried so many things. On one the iterations the template would echo the word “basic” - which is the name of the layout. I was hoping to do something like the following with fieldname:
@include('flexible.'.$fieldname)
which would then call a file within the directory “flexible”
I was hoping to see the words “image” or “text” or “wysiwyg”. From there, I have file “wysiwyg.blade.php,” which contains the following simple line of code:
{!! get_sub_field(wysiwyg) !!}
Within the “flexible” directory, I also tried creating a “basic.blade.php,” which contains the following simple line of code:
{!! get_sub_field(wysiwyg) !!}
Now, I cannot even figure out how I had the word “basic” echo. Now the page is just blank, unless I dump the array in the controller and I can see the entire array. Please help, I have been trying this since this morning