Skip Navigation

[Resolved] Can’t get repeatable group to output data

This thread is resolved. Here is a description of the problem and solution.

Problem: I have an RFG that includes another nested RFG, but I'm having trouble showing fields from both RFGs in a View.

Solution: Use post relationship query filters and the Post Selection tab to create Views that display custom fields from all the different levels of hierarchy.

Relevant Documentation:
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/

This support ticket is created 5 years, 5 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 9 replies, has 2 voices.

Last updated by ericE-4 5 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1313599
image1.png

Maybe it's because I've coded in PHP and javascript (jQuery) and long before that in Visual Basic that I am encountering so many brick walls attempting to do even simple things...maybe I'm just too used to typical coding . I do find that the product design itself is way more complex than it needs to be. It seems like it's been designed by scientists or PhD's even though it's intended for regular WordPress users and developers. Of course the bugs I've found (although to be fair, they are technically just design flaws, but still...) don't help, because I never know if I'm doing something wrong or if it's operating in a totally unexpected and undocumented way. And speaking of documentation, because there's so little of it (the documentation seems to be thousands of possibly-related past support tickets of others, that take hours to sift through) I find that for anything except that absolute basic things requires assistance from a support technician. I suppose that's the strategy--to put the money into staffing the support team rather than improving the intuitiveness of the design--which is not necessarily a bad strategy, because you get to speak with your user group frequently. Anyway, enough of my rant...

I have set up a repeatable group "Package" that contains a field "Package name" and a nested repeatable group "Package Details" which contains 4 other fields. See image 1.

I have created a view "pricing-packages-list". Content selection = "Package" (repeating group). Query filter = "Select posts in Any relationship that are related to the Post where this View is shown."

My loop code:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<div class="packages_wrapper">
		<wpv-loop>
			[wpv-view name="package-row"]
        </wpv-loop>
	</div>
    <!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

The nested view "package-row" looks like this:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
    <wpv-loop>
    	<div class="package">
        	<div class="package-desc">
          		<span class="night=days">[types field='nights' output='raw'][/types] nights / [types field='fishing-days' output='raw'][/types] days fishing</span>
        	</div>
      	</div>
    </wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

I'm basically duplicating what I did (again, with help from tech support because none of it is documented) with another set of nested repeating groups. But when displaying this view it shows "No items found". Not even the outside

<div class="packages_wrapper">

is output. I have no idea why.

#1313907

Hi, where have you inserted the pricing-packages-list View - a template for some post type? a view of some post type?

Please add an indicator to each "no items found" message so we can be clear about which View is not returning results:

<strong>[wpml-string context="wpv-views"]No items found: outer View[/wpml-string]</strong>
<strong>[wpml-string context="wpv-views"]No items found: nested View[/wpml-string]</strong>
#1313943
image1.png
image2.png

I have embedded the view into an Elementor post template via the Toolset View widget. See image 1.

I added the indicators to each view. The output shows the outer view is not returning results. See image 2.

#1314027

Okay assuming the Packages RFG is applied to the post where the View is shown, I can't see an obvious reason why this isn't working. I'll be glad to take a closer look if you provide login credentials here and show me which post you are testing with.

#1314039

In the outer View, I see the setting "Order by field - Nights". However, that doesn't really make sense here because there is no "Nights" field directly in the Packages RFG, only in the nested Package Details RFG. So there could be multiple "Nights" values for any one Package RFG. This is why no results are appearing in the outer View, it's a quirk of how WordPress meta queries work. If the field you're querying by doesn't exist or has no value for some post (or in this case RFG), then that item will not appear in the search results. As a quick test I changed this to Post Date and I saw several results appear, but I reset it to the original setting so you can choose the appropriate option.

Let me know if the results aren't more like you'd expect.

#1314077

That did it...thanks, I never would have figured that out (as again it's not documented and totally not intuitive). Now that I'm able to render output of the view, I've tried to include a value from the outer loop (view is "pricing-packages-list") when outputting the inner loop ("package-row"). I want to output the field "Package name" which is part of the "Package" RFG when looping through the "Package Details" RFG in the inner loop.

I tried using this in the inner loop:

<span class="night-days">[types field='nights' output='raw'][/types] nights / [types field='fishing-days' output='raw'][/types] days fishing</span> | [types field='package-name'][/types] 

but the field "Package-name" is showing up blank.

#1314633

When you insert a field using the Fields and Views button, you'll see a popup appear where you can choose different settings for the field. On the left side there is a Post Selection tab. This is where you can choose the source post that contains the field. In this case, RFGs are handled the same as parent/child post relationships. You'll choose to display information from a related post, and select the inner RFG name as the relationship you want to query.

Check the documentation here for more information about displaying related post information:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/

If you prefer writing code to using the GUI, you can add the "item" attribute to a Types field shortcode manually. The syntax is as follows:

[types field="package-name" item="@package-row.parent"][/types]
#1314809

Hi Christian,

I added the item attribute to the Types shortcode, but it didn't make a difference. Here's my loop code now:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
    <wpv-loop>
    	<div class="package">
        	<div class="package-desc">
          		<span class="night-days">[types field='nights' output='raw'][/types] nights / [types field='fishing-days' output='raw'][/types] days fishing</span> | [types field="package-name" item="@package-row.parent"][/types]
        	</div>
      	</div>
    </wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found: nested View[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]
#1314905

Oh I misunderstood the RFG hierarchy and gave you the wrong identifier. It should be package-details.parent, since the nested RFG is Package Details and you want the package name from the parent Package Row.

[types field="package-name" item="@package-details.parent"][/types]

I made that change in the View so you can see the results.

#1314907

My issue is resolved now. Thank you!