Nested Loopers with conditional display - hiding if a contained element is empty

Using Pro 5.0.0.beta1 / Wordpress 5.7.2

We’re working on a rather complicated “Technical Library” page that is designed to show a list of products which have downloadable documents on them. The Downloadable documents are assigned to the products by use of Advanced Custom Fields, and any given product can have zero, one or more files assigned to it.

Our goal is to show only the products that have downloadable documents, instead of a full list of products with or without downloads.

We have the following setup:

A “Section” with Looper Provider set to Query Builder -> Product / Sort by Title / Count currently 100 (we need this to show all 1200 products minus the ones that don’t have downloads eventually)

Inside that Section we have a single Row with no looper settings, and inside that Row we have a single Column which has the following Looper settings:
Looper Consumer -> All

Now, I assume this column is where we want to have our filter to determine which items are shown, but trying to add a conditional filter here that would limit the display of the rows based on the content of the loopers contained within it (using the Looper Provider and conditional settings that currently are in action on the Download Details Row below) results in no items showing at all.

Inside this Column we have a Headline that is set to show the product title. We don’t want this to repeat above each individual download - we’d like it to appear once for each product that has downloads to view.

Below that, we have a Download Details Row with the following Looper settings:
Looper Provider -> {{dc:acf:post_field field={{dc:acf:post_field field=“downloads”}}

Within this Download Details Row there is a single Column that has the following settings:
Looper Consumer -> All
Conditions: {{dc:looper:field key=“field_604f67a04f66d”}} != 0
If we move the headline into here, we get almost the thing we’re trying to achieve, but not quite - because it duplicates the product headline above each download set, instead of leaving the headline as a title.

Within that there is a Link DIV with a dynamic link leading to the download
Looper Consumer -> All
Looper Provider -> Dynamic Content: {{dc:looper:field key=“field_604f67a04f66d”}}

There is also a DIV containing a Headline with the document’s title
And a Row with additional dynamic content within each of three columns’ text content.

And, of course, just to be difficult, we’d ideally like to filter or paginate the site’s 1000+ product listings in some way so that we don’t have to set the containing Looper’s limit to 1200 items.

Any suggestions or ideas would be most welcome!

Loopers are great way to output data, but unfortunately applying a filter can be difficult in cases like this. Hiding/showing with Element Conditions will cause elements to not appear, but they still exist in the looper. This will throw off your pagination. It also makes it difficult like you’ve discovered to group the data without duplicating parts of it.

Unfortunately, the only way I can think to make this work properly your current data structure that allows for pagination would be a custom SQL query and a custom looper. It also wouldn’t be very good for performance since the SQL queries would have to check unindexed meta data.

I think the best way to solve this would be storing the documents themselves in another post type. You could have and ACF field to hold the documents, and another field to associate the custom post type record to the product record. This introduces some new challenges since managing that in the backend isn’t as ideal. That said, inverting the structure will give you more control over how it’s filtered naturally.

Sorry this might not be what you were hoping for, but hopefully it sheds a bit of light to what’s going on.