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
Hello our.Umbraco Community
I have a Media Picker where i Pick an Folder in my Media Section.
How can i loop trough all images inside this media Folder?
what i have is:
var myFolder = Model.Content.GetPropertyValue("images")
whats the next step?
I want something like this (pseudocode)
@foreach(var image in myFolder){<img src="image.Url"/>}
please help
Kind Regards Hubert
Hi Hubert,
This is a partial view I use for a doctype grid editor I use in one of the older projects.
There is some stuff you don't need for instance a title and all the markup but it should at least get you started. If you have any questions please do ask.
@if (Model != null && Model.MediaFolder != null) { if (Model.Title != null) { <h2>@Model.Title</h2> } if (Model.MediaFolder.DocumentTypeAlias != "Folder") { <a href="@Model.MediaFolder.Url">@Model.MediaFolder.Name</a> } else { <ul class="DownloadTree tree"> @foreach (IPublishedContent node in Model.MediaFolder.Children) { if (node.DocumentTypeAlias == "Folder") { @RenderFolder(node, false) } else { @RenderFile(node, false) } } </ul> } } @helper RenderChildren(IEnumerable<IPublishedContent> nodes) { <ul> @foreach (var node in nodes) { if (node.DocumentTypeAlias == "Folder") { @RenderFolder(node, true) } else { @RenderFile(node, true) } } </ul> } @helper RenderFolder(IPublishedContent node, bool hide) { int childrenCount = node.Children.Count(); <li class="treeFolder @(childrenCount != 0 ? "branch":"")" style="@(hide ? "display: none;": "display: list-item;")"> <i class="indicator fa fa-folder"></i> <a href="#" class="@(childrenCount == 0 ? "empty":"")">@node.Name (@childrenCount)</a> @if (childrenCount > 0) { @RenderChildren(node.Children) } </li> } @helper RenderFile(IPublishedContent node, bool hide) { <li class="treeDownload" style="@(hide ? "display: none;": "display: list-item;")"> @{ <a href="@node.Url" target="_blank" download>@node.Name</a> } </li> }
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
Loop trough picked Media Folder
Hello our.Umbraco Community
I have a Media Picker where i Pick an Folder in my Media Section.
How can i loop trough all images inside this media Folder?
what i have is:
whats the next step?
I want something like this (pseudocode)
please help
Kind Regards Hubert
Hi Hubert,
This is a partial view I use for a doctype grid editor I use in one of the older projects.
There is some stuff you don't need for instance a title and all the markup but it should at least get you started. If you have any questions please do ask.
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.