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
Hi,
How do I access descendants within by media items
This is the structure
main media folder > sub folder > folder > images
I am trying to access the 3rd level folder. I have successfully accessed the subfolder (level2)
Any ideas how you do this within surface controller? I am using umbraco v7
this is my code:
var allItems = Services.MediaService.GetRootMedia(); foreach (var item in allItems) { var d = item.Id; var media = Umbraco.TypedMedia(d); foreach (var folderItems in media.Children) { var s = folderItems.Id; var folderMediaItem = Umbraco.TypedMedia(s); //var allFolderItems = Services.MediaService.GetById(s); if (folderMediaItem != null && folderMediaItem.DocumentTypeAlias.Equals("File")) { var FolderProtected = new MyMediaModel { MediaId = folderMediaItem.Id, MediaName = folderMediaItem.Name //MediaUrl = allMediaItems.Path, // PepFile = pep2, // BimFile = bim2, // ModelingFile = mFile2 }; retval.Add(FolderProtected); } //var getPep = folderMediaItems.GetValue("pepfile"); //if (getPep != null) //{ // bool pep = getPep.GetValue<bool>("bimFile"); //} var sub = folderItems.Children; var subFolders = sub.Where(x => x.Level == 3); foreach (var item2 in subFolders) { var o = item2.Id; var subMediaItem = Umbraco.TypedMedia(o); //if (subMediaItem != null && subMediaItem.DocumentTypeAlias.Equals("File")) if (subMediaItem != null && subMediaItem.DocumentTypeAlias.Equals("File")) { //var allFolderItems = Services.MediaService.GetById(s); var SubFolderProtected = new MyMediaModel { MediaId = subMediaItem.Id, MediaName = subMediaItem.Name //MediaUrl = allMediaItems.Path, // PepFile = pep2, // BimFile = bim2, // ModelingFile = mFile2 }; retval.Add(SubFolderProtected); } } } var allMediaItems = Umbraco.TypedMedia(d); if (allMediaItems != null && allMediaItems.DocumentTypeAlias.Equals("File")) { var MediaProtected = new MyMediaModel { MediaId = allMediaItems.Id, MediaName = allMediaItems.Name, //MediaUrl = allMediaItems.Path //PepFile = pep, //BimFile = bim, //ModelingFile = mFile }; retval.Add(MediaProtected); } }
Thanks
Nav
anybody any ideas?
anybody know how to get all media items in umbraco 7??
I can then work from there
Try this one for multi level
@{ var site = CurrentPage.Site(); if (site != null) { <ul> <li class="@(CurrentPage.Id == site.Id ? "selected" : "")"><a href="@(site.Url)">@site.Name</a></li> @traverse(site) </ul> } } @helper traverse(dynamic parent) { <ul> @foreach (IPublishedContent node in parent.Children.Where("Visible")) { <li> <a class="@(CurrentPage.Id == node.Id ? "selected" : "")" href="@node.Url">@node.Name</a> @traverse(node) </li> } </ul> }
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 items
Hi,
How do I access descendants within by media items
This is the structure
main media folder > sub folder > folder > images
I am trying to access the 3rd level folder. I have successfully accessed the subfolder (level2)
Any ideas how you do this within surface controller? I am using umbraco v7
this is my code:
Thanks
Nav
anybody any ideas?
anybody know how to get all media items in umbraco 7??
I can then work from there
Thanks
Nav
Try this one for multi level
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.