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 2 months ago.

Assisted by: Minesh.

Author
Posts
#2805486
ConditionalRFG.jpg

Tell us what you are trying to do?

On a CPT content template I have several conditional blocks, each containing headings and views of RFGs (example in attached screenshot). I need help with code snippets for the conditional blocks so that headings don't display when the RFGs are empty.

Is there any documentation that you are following?

There's an old thread on this topic here: https://toolset.com/forums/topic/repeatable-field-labels/#post-1374867, but I'm having trouble adapting this.

Each of my RFGs uses just one field type -- single line. Slugs for each single line field, in each RFG, are as follows:

talent2
producer2
director2
camera-op2
sound2
other-crew2

Can you provide me an example of what I should enter in, say, the conditional block for talent2 to prevent the whole block from displaying when the talent2 RFG is empty?

Many thanks!
Djuna

#2805535

In a similar vein, I'd appreciate some help with code snippets for conditional blocks to hide content if the contained "related posts" view has no items found.

As an example, I have a many-to-many relationship between "Projects" and "Distributors" with slug "project-distributor". On my "Project" content template I have a conditional block that contains a heading with text "Distributors" and a view that displays Distributors related to the current Project. If no distributors are found for that project, I'd like all contents of the conditional block to be hidden.

#2805537

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

What you should do is with your conditional block add the condition to check with view's shotcodes and further select "number of items found in view" is greater than zero and check if that help you to resolve your issue.

More info:
- https://toolset.com/course-lesson/using-toolset-conditional-block/#checking-for-shortcodes-values

#2805564
ConditionalBlockProblems.jpg

Thanks Minesh 🙂

Yesterday I tried the condition of the view's shortcode 'number of items found' NOT being an empty value, and today, trying your method ('number of items found' > 0) I get the same unfortunate result: Conditional Block contents are ALWAYS hidden, whether there are view contents found or not.

Please have a look at debugging results in the attached image. While the advanced editor for my Conditional Blocks shows:

( ( '[wpv-found-count ]' gt '0' ) )

I never see 'wpv-found-count' in the debugger. Should I, and if so, do you have any ideas to fix?

#2805572
ConditionalBlockProblem_RFG.jpg

See attached for the same problem for an RFG.

This example uses a simpler view loop as well -- no container and just a single dynamically sourced paragraph element.

Again, I don't see a reference to the view in the debugger.

Here's the page with the debugging code: hidden link

#2805578

Minesh
Supporter

Languages: English (English )

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

Can you please share admin access details and let me check what's going wrong with your setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2805580
ConditionalBlockProblem_NOT_Empty.jpg

Thanks 🙂

I'll share deets after running a backup.

Meanwhile I've added a debug example for the NOT empty condition.

Back in a few when that backup completes...

#2805587

Whoops! Didn't realize I couldn't return to the private form for submitting login details. Can you please resend? Thanks!!

#2805588

Minesh
Supporter

Languages: English (English )

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

I have set the next reply to private which means only you and I have access to it.

#2805589

Meanwhile I deactivated all plugins save for Toolset Types and Blocks.

No change to results in the Conditional Blocks, including debugging results.

I then switched Elementor and Elementor Pro back on but will leave all other plugins deactivated for your check.

#2805591

Minesh
Supporter

Languages: English (English )

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

I have set the next reply to private which means only you and I have access to it.

#2805596

BTW, Another issue I've noticed is that once I've set a Conditional Block dialog to Advanced Editor mode, I can't return to the Visual Editor.

When I try toggling away from Advanced Editor mode, the "Switch to Visual Editor" dialog flashes up for a second (or less), then disappears,along with the Conditional Block editing window. When I next open the editor, I'm still in Advanced Editor mode.

I can work around this, as needed, but... FYI.

#2805722

Hi Minesh 🙂

Will you have a chance to review my issue with conditional blocks today? Fingers crossed...

I'm working on the site today, making frequent backups. While the site is live, it's not yet heavily visited and there are no links to the Projects section implementing Toolset. Feel free to break things, hopefully en route to a fix! I'm monitoring here if you'd like to give me a heads up before going in.

I've left my various tests of conditional blocks as shown in the images I've shared, with debugging turned on. I look forward to turning those off so let me know when you're done, or if you won't be able to have a look today.

Many thanks!!

#2805773

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Minesh is not available today. He will be available on Monday for troubleshooting.

Just for your information, you should not toggle between the Advanced and visual modes as it will reset the code.

There is actually a warning when you try to do that. Please stick with one method and use that.

Thanks.

#2805791

Thanks for the update and heads-up re: mode-toggling, Christopher 🙂

For now I've disabled debug mode and set my conditional blocks for RFGs and related posts views to show content unconditionally.

I look forward to working with Minesh next week.