This is similar to the previous example, except that the CSV file can be uploaded again and again in the App-Settings UI. So the path isn't hard-coded.
@inherits Custom.Hybrid.Razor14
@using ToSic.Razor.Blade
@using System.Linq
@{
// get the query
var query = Kit.Data.GetQuery("ProductsFromCsvInAppSettings");
// get the data from the query
var products = AsList(query);
// get the current author (if available) from the stream Current
var current = AsList(query["Current"]).FirstOrDefault();
// Get the current url params so we can derive from it for details links
var urlParams = CmsContext.Page.Parameters;
}
<ul>
@foreach (var product in products) {
<!-- this li will have class=selected if it's the current one -->
<li class='@(product == current ? "selected" : "")'>
<!-- this creates a link to the current page and product=id -->
<a href='@Link.To(parameters: urlParams.Set("product", product.EntityId.ToString()))'>
@product.Name (#@product.Id)
</a>
@if (current == product) {
<br>
<em>
@current.Description
(<a href="@product.Link" target="_blank">find out more</a>)
</em>
}
</li>
}
</ul>