0

I've created several apps with a single list, but in this specific area I'd like to use two lists in a single app. Is there a way this can be done, and if so how would I refer to the correct list in the repeater/loop?

Here's an example of how I iterate through the items in the list currently:

@foreach (var e in List)
    {
        var Content = e.Content;
        <div class="col-md-3 col-sm-4">
            <div class="staff-info" style="background-image: url('@Content.StaffPhoto'); background-size: cover;">
            @Edit.Toolbar(Content)
                <div class="staff-label">
                    <p class="fullname upper">@Content.Name</p>
                    <p class="jobtitle upper">@Content.Title</p>
                    <hr style="border-color:white; max-width: 90%">
                    <p class="staff-quote"> “@Content.Quote”</p>
                </div>
            </div>
        </div>
    }
Ben
  • 3
  • 1

1 Answers1

0

This is very easy to do. First of all, it's better to iterate the data-stream directly, then the list-object (that was an older way of doing it, but still works). So your loop would be more like

@foreach(var cont in AsDynamic(Data["Default"])) {
        <div class="col-md-3 col-sm-4">
            <div class="staff-info" style="background-image: url('@cont.StaffPhoto'); background-size: cover;">
            @Edit.Toolbar(cont)
                <div class="staff-label">
                    <p class="fullname upper">@cont.Name</p>
                    <p class="jobtitle upper">@cont.Title</p>
                    <hr style="border-color:white; max-width: 90%">
                    <p class="staff-quote"> “@cont.Quote”</p>
                </div>
            </div>
        </div>
}

The Default stream is the same set of information as List, and if you need the presentation items, you can get them as a property of the item like cont.Presentation.

Now, if you have other streams from a query you can just replace Data["Default"] with that stream name, like Data["SortedCategories"].

Or if you want to get all items of a type from the whole app, you can go through the App-object and loop over App.Data["Categories"] and continue from there.

iJungleBoy
  • 5,325
  • 1
  • 9
  • 21