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
1
vote
1answer
541 views

How to order categories in key/value for loop?

This is what I'm trying to accomplish: All categories displayed on one page, with entries returned from each. Only six entries shown in each category. Categories need to be in a specific order. I've ...
0
votes
1answer
2k views

if/else loop with (almost) daily events

Building further on this problem, I try to make a loop that exits when the next opening hours or in other case events are found. There is an event on all days except monday. I added a couple of extra ...
1
vote
1answer
378 views

How can i output my content in pairs?

how can i output my content in pairs? like this: div.row > entry 1 + entry 2 div.row > entry 3 + entry 4 div.row > entry 5 + entry 6 so far i have the following {% for entry in ...
3
votes
2answers
3k views

Outputting Matrix Loop in Template

I have looked at documentation and I still can't figure out how to output the matrix to my template. The Field handle name is: threeHomepageImages The Block type handle name is: images The Fields ...
1
vote
1answer
1k views

More efficient matrix count method

I have some logic in a template where I want to count the number of items that have a lightswitch set to yes, and a radio button set to another value, currently I'm doing this via a series of {% set %}...
3
votes
1answer
446 views

How would I list assets from a specific subfolder?

In the case that I have an asset folder structure like this: /images /group-a /group-b /group-c How would I loop through all of the images in /group-b without having to assign them to ...
2
votes
2answers
456 views

Using a loop in a loop, how do I check if child loop is empty to not display parent loop?

I'm trying to display a list of names alphabetically ordered. This is working fine, but I also want to check if the name is intoCollection or not (using a Lightswitch). If it is intoCollection, it ...
2
votes
1answer
1k views

How do I create a list of categories and display the entries relating to each of these categories that have at least one entry?

Here's a summary of what I try to do: I created a Single page with a specific template where I want to display a list of partners I created a group of Categories to define all types of partners All ...
8
votes
4answers
6k views

Remove the last comma in an inline list of tags?

In a list of tags I'd like to remove the last comma. So is there something that works like the Ee backspace parameter?
4
votes
2answers
691 views

Fetch Single asset without for loop?

I've got a Assets field which is limited to 1 asset inside a Matrix field. Is there a better way to fetch the image without using a forloop? At the minute I've got: {% for image in block....
4
votes
1answer
384 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....
8
votes
1answer
2k views

How do you filter matrix blocks by type?

Is there a way to filter a matrix by block type, or get a count of how many items there are of a certain type? Can't find a syntax example. I created a matrix with two blocks. In pseudo code, ...
6
votes
1answer
1k views

How do you return a message if no entries are found?

I thought this would be very easy but I'm having a hard time figuring it out. How do you output a warning/message if there are no entries to loop through? {% set entries = craft.entries.section('...
9
votes
2answers
11k views

Is it possible to break out of a loop in twig?

Is it possible to break out of a loop in twig? If it is, how would I do it?
3
votes
1answer
3k views

How do I loop through entries for a specific entry type?

I would like to loop through entries in a channel but only the ones for a specific entry type. Is this Possible? I'm using the free version of craft on a test site, I have used the channel for my ...
5
votes
2answers
3k views

How to correctly output a Table Field?

I have set up a Matrix field with three blocks, each contains a Table field. Each table has one column - a single line text field. When I call these tables into the template with this code, each row ...
4
votes
1answer
1k views

How to create new variable from For Loop results

I need to get a list of all the "sizes" from my Table type field column. The list of sizes needs to be separated by a "|"... eg: small|medium|large My Table type field name is "productAttributes" and ...

1 2
3