Hey I can't get my head around this and haven't worked to much in Sitecore but can anyone help? The code is getting the children of a item putting them into an array and then running another section depending on the items in the array. What I want is to remove any items that doesn't have the current language version. Here is what I've got. Even telling me I'm on the wrong track will help Thanks.
@{
var detailPages = Sitecore.Context.Item.Children.AsStronglyTypedCollectionOf<IDetailPageItem>().ToArray();
@foreach (var detailPage in detailPages)
{
if (Sitecore.Context.Item.Versions.Count == 0)
{
Array.remove(detailPages, detailPage);
}
}
if (!RenderingContext.IsEditing && detailPages.Length == 0)
{
return;
}
}
<div class="cardsmenu">
<div class="wrapper">
@if (RenderingContext.IsEditing && detailPages.Length == 0)
{
<p class="edit-only">No detail page children exist. This list will be invisible when viewed outside edit mode.</p>
}
@foreach (var detailPage1 in detailPages)
{
@Html.Partial("/Areas/mytestsite/Views/Shared/DetailPageLink.cshtml", detailPage1)
}
</div>
</div>