Skip Navigation

[Resolved] Code to conditionally hide labels for empty repeating field groups?

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 0 reply, has 1 voice.

Last updated by Djuna 1 month, 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2806587
Conditional_Block_Observations.jpg

More discoveries re: Conditional Blocks!

1) I have sufficient resolution for this issue. This post shares lessons learned.

2) I found why "Views > 0" wouldn't work for my setup, and I'm now correcting my setup. The good news is: View count works logically (with the understanding it counts ALL repeating fields, even empty ones). No need to elevate a view count issue. But a way to count all non-empty fields would be welcome 🙂

3) I've found that my posts have a strange "initial state" wherein Conditional Blocks based on RF view counts, as well as those based on "helper fields" (e.g., my manual switches, described earlier) don't work as expected until after a Post Update. See attached image. If this is a caching issue, it is a stubborn one, as an update to the individual post (not the template, with its changes visibly rendered on the post) is the ONLY way I've found to 'wake up' Conditional Blocks. (And, no, I don't have any View Cache switched on.)

4) Once overcoming the last challenge, I could begin to see my setup problem: **Repeatable Field sets that contain ***only empty fields*** (or a single empty field) for several posts**.

My Sound Group, for instance, was set up with an empty single-line field, for which only some posts have data. This presents no issues in View Loops, but it does for CBs. Examining CB debug results (AFTER updating a post!) shows me that counts of both "views found" and "views displayed on page" return ***the total number of fields in the Repeatable Field set***, whether or not those fields contain data. (I expected, and would still be grateful to find, a test based on a non-empty field count.)

Why do I have RF sets with fields and no data? Because I used WP All Import without selecting the option "Ignore blank fields" for repeatable groups. Live and learn!

#2806592

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thank you for sharing all those information.

You can check the empty custom field within the view's loop not outside the view's loop. That is why in your case you will have to be dependent on the post count.

#2806600

Ah okay, thanks for letting me know.

Very strange this behavior I'm seeing where "virgin" posts have different results in CBs than updated posts. Just now I opened a post for the first time, saw that my CBs based on "helpers" weren't working, entered Edit Post, hit Update and found that wasn't quite enough. Making a change to the page (even a slight change, in an unrelated block), then saving the update, wakes up the CBs. Here's hoping they stay woke!

Many thanks!!