How do I get the count of a repeating object in a custom module?
SOLVE
Hello,
Feels like such a simple thing to calculate, but I'm struggling to find a solution.
I have created a custom module, it holds different logos. I'm using the "for item in" loop to display the logos in a grid.
When the number of logos present is > 4 I want to output a different layout and structure, with slider controls etc. So I would like to calculate the count of items and use this in an IF/ELSE structure for this logic.
I tried using .count on the repeater object "module.logo" to get the number of logos to make the logic work, like so:
module.logo.count()
I also tried:
module.logo.count('item')
But this returns 0 no matter how many logos have been added
Is there a simple way to get the count of repeater items in the module?
Or do I have to loop through them and add 1 to a variable to get a custom variable with the count in it?
I know I could add .count logic within the for loop but my code would be a lot cleaner if I could calculate this outside of the loop first.