1
votes

I need to do a simple list of images. I tried to add a content module and make a new template with my custom content (image, title, url).

Here is the code of my template:

@foreach(var Element in List) {
var Contenuto = Element.Content;   
<div>
  @Contenuto.Immagine
</div>
}

Found @List.Count entries

Even if I added more contents it shows just the first. Then I tried to do it as an app, same thing, showing only the first item. Finally I tried to do a query for my app and it shows all items.

What am I missing please? Is there a way to do it as a simple content?

Thank you

1

1 Answers

0
votes

The @foreach(element in List) is an older syntax which still works, but the content-item is then found on element.Content. The rest is the same.

But: it would be better to loop through Data["Default"] as it gives a more consistent use of the items, which is also coherent to other use cases. Read more about it here: https://github.com/2sic/2sxc/wiki/Razor-Data