Skip Navigation

[Resolved] Hiding title of when repeatable fields are empty

This support ticket is created 5 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by bryanC-2 5 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1233615

Tell us what you are trying to do?

I have the headings of "Sponsors", "Cast" and "Crew" for repeatable fields that you can see here. hidden link

I want to set up the page so if a section has no repeatable field used, the heading for the section disappears.

Is there any documentation that you are following?
https://toolset.com/forums/topic/hide-text-field-if-custom-field-is-empty/
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

I've tried these expressions with no luck. I'm wondering if the issue is because the field is repeatable.
[wpv-conditional if="(sponsor)"]
<h4>Sponsors</h4>
[/wpv-conditional]

[wpv-conditional if="( $(sponsor) eq '' )" ] [/wpv-conditional]
[wpv-conditional if="( $(sponsor) ne '' )"]
<h4>SPONSORS</h4>[/wpv-conditional]
[wpv-conditional if="( $(sponsor) ne '' )"]
[types field='director'][/types][/wpv-conditional]

What is the link to your site?
hidden link

Any help again is appreciated.

Thanks
Bryan

#1233634

Dear Bryan,

How do you setup the repeatable fields "Sponsors", "Cast" and "Crew"?
Are they custom custom repeating fields or repeatable field groups?

If they are repeatable field groups, I suggest you follow our document to create a post view:
- query "Sponsors" posts
- filter by the relationship "Sponsors"
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups
- in section "Loop Editor", within shortcode [wpv-items-found] ... [/wpv-items-found]
Display the h4 title: <h4>SPONSORS</h4>

More help:
hidden link

And you can share your website credentials in below private message box.

#1234100

Thanks for the details, for example the "Show Sponsors" repeatable field groups, you can move the HTML div wrapper into the child view "sponsors-4-column", I have setup a demo in your website:

1) Edit the content template: Individual Show Page
hidden link

Change the codes from:

<div class="sponsors wrap">
  <h3>Sponsors</h3>
  <div class="sponsor">
[wpv-view name="sponsors-4-column"]
  </div>
</div>

To:

[wpv-view name="sponsors-4-column"]

2) Edit the post view "sponsors-4-column", in section "Loop Editor", change the codes from:

...
	<!-- wpv-loop-start -->
...
	<!-- wpv-loop-end -->
...

To:

...
<div class="sponsors wrap">
  <h3>Sponsors</h3>
  <div class="sponsor">
	<!-- wpv-loop-start -->
...
	<!-- wpv-loop-end -->
  </div>
</div>
...

If you don't want to display anything when there isn't child item in "Show Sponsors" repeatable field group, you can remove those codes:

<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>

Save as above, you can move the HTML div tags into other child post view for Cast and Crew.

For your reference.

#1235929

Great support