Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am writing a Media Folder Viewer.
When I call the ChildrenAsList on a DynamicMedia I get an List<DynamicBackingItem>.
How do I group the items into groups of 4?
@using umbraco.MacroEngines; @using umbraco.cms.businesslogic.media; @helper BuildTable(dynamic mediaList) { <table border="0"> <tbody> @foreach (var item in mediaList) { <tr> <td align="center"><img src="@item.GetProperty("umbracoFile").Value" alt="" /></td> </tr> } </tbody> </table> } @helper BuildTable2(dynamic mediaList) { <table border="0"> <tbody> @foreach (var group in mediaList.InGroupsOf(4)) { <tr> @foreach(var item in group) { <td align="center"><img src="@((DynamicMedia)item).umbracoFile" alt="" /></td> } </tr> } </tbody> </table> } @{ if (String.IsNullOrEmpty(@Parameter.MediaFolder)) { <div>A Folder has not been selected</div> } var folderId = @Parameter.MediaFolder; var media = Model.MediaById(folderId); var items = media.ChildrenAsList; if(items.GetType() == typeof(DynamicNull)) { <div>Cannot Find the Folder (@folderId)</div> } else if(items.Count <= 0) { <div>Folder is Empty</div> } else { @BuildTable(items); } }
you should use .Children instead of .ChildrenAsList in this case.
thanks, that fixed it.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Media List Iteration routine - Missing InGroupsOf on List<DynamicBackingItem>
I am writing a Media Folder Viewer.
When I call the ChildrenAsList on a DynamicMedia I get an List<DynamicBackingItem>.
How do I group the items into groups of 4?
you should use .Children instead of .ChildrenAsList in this case.
thanks, that fixed it.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.