Tell us what you are trying to do?
I want to check if a repeatable field group is populated.
I tried using the if empty condition then hide but that doesn't seem to work.
Hello,
The Toolset repeatable field groups is based on one-to-many relationship, each item of repeatable field groups is also a post, so it needs a post view, for example, create a post view:
- Query posts of your "repeatable field groups"
- Filter by relationship of your "repeatable field groups"
- In section "Loop Editor", within shortcode [wpv-no-items-found] ... [/wpv-no-items-found]
Display the information you want.
More help:
hidden link
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/
I'm using Views to show the repeatable field group.
<h3>How to become one</h3>
[wpv-view name="rfg-career-requirements"]
For example, I want to hide the <h3> tag if the RFG view doesn't show a result.
You can move the HTML codes:
<h3>How to become one</h3>
Into view "rfg-career-requirements", section "Loop Editor", within shortcode [wpv-items-found] ... [/wpv-items-found]
Another workaround is using CSS codes, for example:
1) Wrap your codes in a DIV tag:
<div class="hide-on-empty">
<h3>How to become one</h3>
[wpv-view name="rfg-career-requirements"]
</div>
2) Edit view "rfg-career-requirements", In section "Loop Editor", within shortcode [wpv-no-items-found] ... [/wpv-no-items-found], display CSS codes:
<style>
.hide-on-empty{display:none;}
</style>
Thanks for the reply, Luo.
The <h3> can't be in the View. If I put it in the View, I can't use it in other blog posts. Hence I need it to be separated.
As I mentioned above, you can try the CSS workaround:
https://toolset.com/forums/topic/how-to-check-if-repeatable-field-group-is-populated/#post-1655081
If you need more assistance for it, please provide a test site with the same problem, I can setup a demo for you.
How about hiding a <div> on the same page if the View is empty?
For example,
On this page (hidden link), the RFG is the content under "How to become one". Screenshot: hidden link
I want to hide the
How to become one
in the Table of Contents. Screenshot: hidden link
Stan
You can try these:
1) Modify the HTML link codes as below:
<li class="hide-on-empty"><a href="#requirement">How to become one</a></li>
2) Edit view "rfg-career-requirements", In section "Loop Editor", within shortcode [wpv-no-items-found] ... [/wpv-no-items-found], display CSS codes:
<style>
.hide-on-empty{display:none;}
</style>