Sorry if this is a novice question but i have looked across this forum and unable to locate a solution for my issue.
One of our website have requested to be able to simple upload a number of items into a selected folder in the media section of Umbraco and this folder to be displayed on a page is a list format (links to the items aswell).
the folder is set two levels down in the media folder
My question is how to gather the items from this folder and display them in the best method?
once again sorry if this is a dumb question. this is the first time I've ever attempt to gather information from a media folder so i would be grateful for the support
Do you want to link the Media folder to a certain page or do you want to retrieve a Media folder from any Template/View?
If you want to link a Media folder, you can modify the Document Type and use a Media Picker as the property editor. This way you can retrieve the Media folder from the Template/View in the same way you retrieve normal properties: Model.Value<IPublishedContent>("mediaFolder"). This will then allow you to retrieve all Children or Descendants using the functions .Children() or .Descendants().
If you are using ModelsBuilder the media items can be retrieved in a similar way using Model.MediaFolder.Children().
If you want to link a Media folder, you can modify the
Document Type and use a Media Picker as the property editor. This way
you can retrieve the Media folder from the Template/View in the same
way you retrieve normal properties:
Model.Value
I Think this is the what i am attempt to do, I basically want to display every child item within the Minute folder in a list. i will go away and try and use this information.
This is a complete guess but am i looking for something like this below:
var media = Model.Value<IPublishedContent>("Minutes");
var meetingItems = Media.Children();
@foreach (var item in MeetingItems)
{
here I do stuff..
}
Displaying Media Folder within a page
Sorry if this is a novice question but i have looked across this forum and unable to locate a solution for my issue.
One of our website have requested to be able to simple upload a number of items into a selected folder in the media section of Umbraco and this folder to be displayed on a page is a list format (links to the items aswell).
the folder is set two levels down in the media folder
My question is how to gather the items from this folder and display them in the best method?
once again sorry if this is a dumb question. this is the first time I've ever attempt to gather information from a media folder so i would be grateful for the support
?
Hi Paul,
Do you want to link the Media folder to a certain page or do you want to retrieve a Media folder from any Template/View?
If you want to link a Media folder, you can modify the Document Type and use a
Media Picker
as the property editor. This way you can retrieve the Media folder from the Template/View in the same way you retrieve normal properties:Model.Value<IPublishedContent>("mediaFolder")
. This will then allow you to retrieve all Children or Descendants using the functions.Children()
or.Descendants()
.If you are using ModelsBuilder the media items can be retrieved in a similar way using
Model.MediaFolder.Children()
.If you want to retrieve a specific Media folder on any Templates/Views, you can use the
MediaService
, more information on Our Umbraco: https://our.umbraco.com/documentation/reference/management/services/mediaservice/.Note: You might want to include some null-checks to make sure the page doesn't break.
If you have any further questions, let me know and I will try to help.
Hi Jeffery,
I Think this is the what i am attempt to do, I basically want to display every child item within the Minute folder in a list. i will go away and try and use this information.
This is a complete guess but am i looking for something like this below:
the Items are not Images, they are PDF btw
Hi Paul,
The code you provided should work, are you sure you set the Media Picker property editor to allow only a single item to be selected?
If this isn't the case, you might want to try retrieving the data as an
IEnumerable
instead:I tried retrieving a Media folder by id and displaying it's children, which worked as expected:
Let me know if this may fix your issue
Would this work with PDF Format? i just want to display the name of the document and also the link to the item.
thanks
Yes, should work as it's just a
File
type:Jeffrey for you help on the matter, manage to get it all up and running without any major issues.
thanks again
is working on a reply...