Hi! Im testing Umbraco 8 and got stuck on getting files the way I'm used to.
I just made a simple loop to iterate through all folders and files in the media section but no files where found, only the folder..? I did this in a Partial view.
var DocRootFolder = Model.Parent.Value<Folder>("docFolder");
<ul class="docs">
@foreach(var folder in DocRootFolder.Children)
{
<h2>@folder.Name</h2>
<ul>
@foreach(var doc in folder.Children)
{
<li>
<a href="@doc.Url">
@doc.Name
</a>
</li>
}
</ul>
}
</ul>
I also tried to directly access an image just to see if I could get a hit but that gives me an error.
var mediaItem = Umbraco.TypedMedia(1234);
Are there any documentation ready for how to work with the media section?
Yes, that is nice but now working for me in Umbraco 8.
"'UmbracoHelper' does not contain a definition for 'TypedMediaAtRoot' and no accessible extension method 'TypedMediaAtRoot' accepting a first argument of type 'UmbracoHelper' could be found (are you missing a using directive or an assembly reference?)"
Cant get media items
Hi! Im testing Umbraco 8 and got stuck on getting files the way I'm used to.
I just made a simple loop to iterate through all folders and files in the media section but no files where found, only the folder..? I did this in a Partial view.
I also tried to directly access an image just to see if I could get a hit but that gives me an error. var mediaItem = Umbraco.TypedMedia(1234);
Are there any documentation ready for how to work with the media section?
Hi,
I think Alex has answered this one before..
https://our.umbraco.com/forum/templates-partial-views-and-macros/87221-list-all-media-items-from-media-library
Yes, that is nice but now working for me in Umbraco 8.
"'UmbracoHelper' does not contain a definition for 'TypedMediaAtRoot' and no accessible extension method 'TypedMediaAtRoot' accepting a first argument of type 'UmbracoHelper' could be found (are you missing a using directive or an assembly reference?)"
I believe the current equivalent would be:
Current.UmbracoHelper.MediaAtRoot()
there is also
Current.UmbracoContext.MediaCache.GetAtRoot()
Just realized when testing that there were no problem with my initial code..
I deleted the pdf-files I uploaded and added them again and then they popped up! Strange!
So forget all I wrote :)
is working on a reply...