Questions tagged [forloop]

For loop is a statement executing some code repeatedly (forever or till some condition exists it)

Filter by
Sorted by
Tagged with
2
votes
3answers
615 views

Making an entry grid with Batch 2,3 (2 in row then 3 in row)

I'm trying to make a News item grid. I'm looking for a solution to output 2 type of "rows". One that shows 2 entries and the other shows 3 entries. I tried playing around with batches already but can'...
10
votes
1answer
4k views

Advanced query/filter based on date and values

I have a channel of events with a field ‘eventDate’ for the date/time of the event. Within that there are ‘types’ of events ‘eventType’. What would be the most efficient way of outputting the NEXT (...
5
votes
1answer
1k views

Group looped entries into blocks and wrap in markup every x number of loops

I am trying to loop through all the entries in a section and "group" them into items which are in blocks of 9 then wrap them with some html markup so there will be the following code: {% set ...
1
vote
2answers
1k views

Matrix loop nesting issue using switch

Anyone know if it's possible to check what the current field is while in a loop of a matrix block? Running into an issue with a matrix block in my loop for how I want to output the content. {% case '...
1
vote
1answer
120 views

Looping through returns nothing after using dynamic routes to get the entry type and category

I'll explain a bit of the structure of the content and then proceed to the issue. So i have a website with a shop in it with the url mysite.com/shop/, it is an channel section, and its template is ...
4
votes
1answer
378 views

How can I iterate more than 100 blocks in a matrix field for loop?

I am looping through a matrix field and it appears to stop looping when the index reaches 100 but I have more than 100 blocks here. How can I loop through the remaining blocks? {% for block in entry....
2
votes
2answers
5k views

Total sum within loop

I have simple loop: {% for total in thing %} {{ total.seatsKids }} {{ total.seatsParents }} {% endfor %} This results in a string of numbers eg. 1 3 4. I want the sum of all numbers. So how do I ...
1
vote
1answer
216 views

Match Matrix Fields Before Looping Through Results

I hope someone has an example or something similar they have done in Craft before. Her is what I have. Structure: Section -> Flight Company Matrix Name -> Plane Details Matrix Block: Plane Model ...
1
vote
1answer
627 views

For loop, if statement, then limit

I've created two global variables which my content creator is going to use to turn off a bunch of articles and turn on a bunch more which a slight change in the Global. I have a page where there is a ...
0
votes
2answers
251 views

How do I omit similar content in a for loop based on the first letter in title?

I've got a for loop that is returning the first letter of the entry title. I have a number of entries so I almost get a complete alphabet except that there are too many of many letters. I only want ...