Display Provider item count outside Consumer

Hi Support,

Is it possible to display a Looper Provider count outside of a Looper Consumer? {{dc: looper: count}} only works in a Consumer. This is not desirable as I only want to display the count once.

One extra Looper Provider with the setting to return only 1 item is also not an option. This causes the original Looper to return one less item. Although the Loopers / Consumers are completely independent in the builder, they seem to be connected in the background.

Looper Provider type: Dynamic Content
Looper Provider input: {{dc: acf: post_field field = “acf_repeater”}}

Thanks,
Matthijs Smeets

Edit: Title

Hello Matthijs,

Thanks for writing in!

The Looper Provider sets up what kind of loop and the Looper Consumer runs the loop. The provider item count needs to be inside the consumer. You can use two consumers inside the Looper. One consumer will return 1 and then the second consumer can return All.

Hope this helps.

Hi @ruenel,

This has the same effect as two Providers / Consumers.

If I adjust the first Consumer to display one value it has a direct effect on the second Consumer. The second Consumer returns one less value.

Hi Matthijs,

I will suggest you to add a Text element that contains {{dc:looper:count}} and set the condition to it for print for {{dc:looper:index}} is equals to 1. Please find the screenshot describing the settings and options.

Hope it helps.
Thanks

Hi @tristup,

Thanks for your input!

That is indeed a solution if there are items. There will have to be a separate element / condition if there are no items.

Quite some configuration and elements to maintain. An extra consumer also feels a bit redundant.

For now I have solved it with the shortcode below which I can use in one element without conditions:

function VBY_Ticket_Count()
{
    $items = get_field('array_ticket');
    if (is_array($items)) {
        return count($items);
    }
    return 0;
}
add_shortcode('VBY_Ticket_Count', 'VBY_Ticket_Count');

Best regards,
Matthijs

Hi Matthijs,

Great to know that you are able to solve it.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.