Condition to hide DIV if ACF repeater field is empty

Hi

The goal is to hide a containing DIV if the ACF repeater content is empty. I’ve tried numerous strings in the conditions but can’t seem to work it out.

Fig 1. This is a single layout with a div with a dc looper provider for the ACF repeater field.

Fig 2. There is a text element that calls the repeater field

Fig 3. THE GOAL, to hide the whole containing DIV if the ACF repeater field is empty

Hi @henrybag,

Thank you for writing in, on the hide condition you can use the Provider Output is empty condition.

But if you want this to be applied on the container div, you need to move your Looper Provider on that container div, the nested div can remain as the Looper Consumer.

Hope it helps,
Cheers!

Many thanks for the reply - I’m still not getting the results I need from those settings, probably a user error on my end!

The goal is to hide the title ‘Key Stages’ if there are no stages (ACF repeater fields) added in the admin. I thought you would be able to hide the enclosing DIV so that the title is hidden as well but can’t get it working.

On the screenshot above you have the condition, looper provider and consumer all applied to the outer div? When I apply that it doesn’t work. Have I misunderstood your instructions?

Thanks
H

To chime in on what I think is the same topic, I find the ACF Repeater fields follow a different logic than other loopers.

I have set up a loop that is being fed from the Repeater. Each repeater has a checkbox that can be 0 or 1. I want to hide the elements in the loop that have a value of 0. However, when I search for the custom keys, each field in each row in the Repeater has its own generated key. I haven’t found a way to say this:

If a row in the Repeater field has a checkbox set to 0, hide the entire Consumer element and leave the other repeated elements.

Hey H,

To your question:

Yes. I’m referring to the Repeater Field itself. Your structure should look like the following screenshot. Note that the Row and Columns could be a Div.

image

Inside the Repeater element, you’ll have the Sub Field Provider. This time, it won’t be a Consumer because you’ll have the “Key Stages” headline inside it. This Sub Field Provider element will have the Provider Output IS NOT Empty condition so if your Sub Field is not empty, it will display the list.

image

Inside the Sub Field element, you’ll have your Static Headline (represented by the Alert element in the screenshot below) and the Consumer Text.

image

The static element which would be your Key Stages headline would just need to have the Consumer Output is initial Condition so it won’t be repeated.

I’ve tested that setup and it is working. When the List is empty, the whole Row won’t be displayed.

image

If you have something on the List, it will display

image

image

Just to make your setup clean, you can opt to make the Sub Field Provider be the Consumer also so you’ll just have the Static and Dynamic elements inside it.

image

Hope that helps.


@Misho, I’m not sure if this applies to you so it would be best that you open up a new thread.

Thanks.

@christian Thanks for this in depth walk through - it was really useful as was stumped by it.

Following on from it, I have 3 of these in one column. All individually work and hide when they don’t have any content.
Though I want to hide the master column if neither of the 3 have any content - is that possible?

Link in case it helps, the column on the right ‘resources’: https://healthinhampshire-com.rubberduckers.agency/covid_booster/article/ - videos, documents, and links are the loopers.

Hi @RubberDuckers,

Please provide us login credentials in a secure note so we can take a look on your setup. Please write it on your own thread since the original poster can see the secure note here.

Thanks,

Hi @RubberDuckers,

Your question has been already answered in the following thread.

Thanks

Thanks, sorry I only saw the suggestion of starting a new thread after I’d posted there. Have responded there too so can consider this one closed.

Hi @RubberDuckers,

Thanks for letting us know.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.