1

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 Answers1

0

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

iJungleBoy
  • 5,325
  • 1
  • 9
  • 21
  • Thanks for your reply, I didn't see that documentations. So anyway I see that if I want to loop all items I have to make an application. With a content I can only work one item per time and not loop on all items even if I added more they stay separete. – Giovanni Manzo Oct 08 '16 at 08:37
  • you don't really have to create an App, the App-variable exists in Content as well. But as soon as you're doing data-style-things, it's usually better to create an app because it usually goes beyond the scope of what "Content" is targeted – iJungleBoy Oct 10 '16 at 08:24
  • btw: if this answered your questions, pls mark as answered. – iJungleBoy Oct 10 '16 at 08:24
  • Ok, now I understand the difference between app and content :) Thanks you – Giovanni Manzo Oct 10 '16 at 14:11