In my front page controller, I have a function that I would like to return the value of an ACF repeater field ($friends_logos
), but it’s coming through blank. Other ACF fields ($friends_title
) are coming through as expected everywhere this partial is used.
Wondering if missing something key here in the logic. Is that data not allowed? Do I have to declare it or something?
Here is my Front Page Controller:
<?php
namespace App\Controllers;
use Sober\Controller\Controller;
class FrontPage extends Controller
{
public function signup_img_t()
{
return \App\asset_path('images/footer/separator-whitebg.svg');
}
public function friends_title()
{
return get_field('friends_&_supporters_section_title', 'options');
}
public function friends_logos()
{
return get_field('friends_supporters_logos', 'options' );
}
}
Here is my template part
<?php
echo $friends_logos." = friends logos<br/>";
echo var_dump($friends_logos);
$logos = get_field('friends_supporters_logos', 'options' ); ?>
@if ($logos)
<div class="white-bg petrol">
<img loading="lazy" src="{!! $getinvolved_menu_imgt !!}">
<div class="container py-5 ">
<div class="col">
<div id="supporters">
<h3 class="text-center p-5 my-5 head coral">{!! $friends_title !!}</h3>
<div class="d-flex justify-content-between flex-wrap">
@foreach( $logos as $logo )
@php
$img = $logo['friends_logo'];
echo wp_get_attachment_image( $img, 'full' );
@endphp
@if ($logo['friends_link'])
<a href="<?= $logo['friends_link'] ?>" title="<?= $logo['friends_title'] ?>" target="_blank">
<img loading="lazy" src="{{ $img }}" class='p-1'>
</a>
@else
<img loading="lazy" src="{{ $img }}" class='p-1'>
@endif
@endforeach
</div>
</div>
</div>
</div>
</div>
@endif
And here is the ACF
{
"key": "field_60f57b90d7d57",
"label": "Friends & Supporters Logos",
"name": "friends_supporters_logos",
"type": "repeater",
"instructions": "This will fill the friends and supporters area with the approproate logos. The more you put in her the larger your co2 score for this page so try and be moderate! The co2 calculator at the bottom will update once per day with a new score so keep an eye on that if you add a lot of logos and check the score again the next day.",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"collapsed": "",
"min": 0,
"max": 12,
"layout": "table",
"button_label": "Add Another Logo",
"sub_fields": [
{
"key": "field_60f57bb7d7d58",
"label": "Logo",
"name": "friends_logo",
"type": "image",
"instructions": "Please compress your image using https:\/\/tinypng.com\/ to achieve the minimum filesize possible.",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"return_format": "url",
"preview_size": "medium",
"library": "all",
"min_width": "",
"min_height": "",
"min_size": "",
"max_width": 180,
"max_height": 180,
"max_size": "0.25",
"mime_types": ".png, .jpg"
},
{
"key": "field_60f57c4565dbd",
"label": "Link",
"name": "friends_link",
"type": "url",
"instructions": "Use this to add a link to the supporter.",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "",
"placeholder": ""
},
{
"key": "field_60f5a84e0e2ab",
"label": "Title",
"name": "friends_title",
"type": "text",
"instructions": "Giving the proper name of the organisation you are linking to will help with site SEO.",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": ""
}
]
},
THank you for any help in my understanding!