Thanks for the reply! I've added the code but get this error below, am i missing a @inherits maybe?
Error:
CS1061: 'Umbraco.Web.Models.RenderModel' does not contain a definition for 'MediaById' and no extension method 'MediaById' accepting a first argument of type 'Umbraco.Web.Models.RenderModel' could be found (are you missing a using directive or an assembly reference?)
Line 5:
Line 6: if(!String.IsNullOrEmpty(Model.MediaPickerAlias)){
Line 7: var gallery = @Model.MediaById(Model.MediaPickerAlias); Line 8: foreach(dynamic item in gallery.Children){
Line 9: @item.Name
Try using this code in your template where you are planning to add this functionality or may be just create a new cshtml file from the developers section.
@{ if(!String.IsNullOrEmpty(Model.MediaPickerAlias)){ var gallery =@Model.MediaById(Model.MediaPickerAlias); foreach(dynamic item in gallery.Children){ @item.Name } } }
Pick up media folder dynamically
Hello
I am trying to loop through a media folder and display the images on the page.
Does anyone know how I can replace the hardcoded folder id with that set by the user in the "Content" section using the "Standard Media Picker"?
Thanks Paul
Hi Paul,
Hope this helps
Fuji
Hey Fuji
Thanks for the reply! I've added the code but get this error below, am i missing a @inherits maybe?
Error:
CS1061: 'Umbraco.Web.Models.RenderModel' does not contain a definition for 'MediaById' and no extension method 'MediaById' accepting a first argument of type 'Umbraco.Web.Models.RenderModel' could be found (are you missing a using directive or an assembly reference?)
Line 5: Line 6: if(!String.IsNullOrEmpty(Model.MediaPickerAlias)){ Line 7: var gallery = @Model.MediaById(Model.MediaPickerAlias); Line 8: foreach(dynamic item in gallery.Children){ Line 9: @item.Name
Hi Paul,
Try using this code in your template where you are planning to add this functionality or may be just create a new cshtml file from the developers section.
Hey Fuji
Sadly still not working for me...dont suppose I could ZIP it all up and email you it and see if you can see the issue?
Cheers Paul
Yes you can send it to me
hey i dont have your email but i tweeted u a link to my public drop box :
thanks :)
:) were u able to access file okay? Cheers Paul
It should be working now .
totally awesome - i am very thankful to you for this :)
---
Paul
is working on a reply...