Run*_*ion 3 if-statement umbraco count razor
我该如何在剃刀中做到这一点:
如果(我认为)剃刀(C#/ umbraco)中的结构,我该怎么做?
@inherits umbraco.MacroEngines.DynamicNodeContext
<ul class="image-gallery">
@foreach (var item in @Model.fotoGallerij)
{
<li>
<a class="gallery grouped" href="/ImageGen.ashx?height=500&constrain=true&crop=resize&image=@item.Image.umbracoFile" title="">
<img src="/ImageGen.ashx?width=71&height=73&crop=resize&image=@item.Image.umbracoFile" alt=""/></a>
</li>
}
</ul>
<script>
$("a.gallery").colorbox({rel:'grouped'});
</script>
Run Code Online (Sandbox Code Playgroud)
感谢您的帮助!
Razor实际上是C#,因此您可以使用C#进行任何操作,也可以使用Razor。这样的事情应该起作用:
@inherits umbraco.MacroEngines.DynamicNodeContext
@if (Model.fotoGallerij.Count() == 1)
{
// Display only the one here...
}
else if (Model.fotoGallerij.Count() > 1)
{
// Loop through the list of items here...
}
Run Code Online (Sandbox Code Playgroud)