For the media you can use the built in code-snippet called List Images From Media Folder, then the user can pick a media folder in the media section, and then you loop through the images in this folder.
You can do it using a partial view macro, then when you add the macro to the template, and pick the folder in media section
@inherits Umbraco.Web.Macros.PartialViewMacroPage @* Macro Parameters To Create, for this macro to work: Alias:mediaId Name:Media Folder ID Type:Single Media Picker *@
@if (Model.MacroParameters["mediaId"] != null) { @* Get the media folder as a dynamic node *@ var mediaFolder = Umbraco.Media(Model.MacroParameters["mediaId"]);
if (mediaFolder.Children.Any()) { <ul> @* for each item in children of the selected media folder *@ @foreach (var mediaItem in mediaFolder.Children.Take(3)) { <li> <a href="@mediaItem.Url"><img src="@mediaItem.umbracoFile" alt="@mediaItem.Name" /></a> </li> <p>test:@mediaItem.lastEdited</p> <p>updated @mediaItem.updateDate.ToString("HH:mm") on @mediaItem.updateDate.ToString("dd MMM yyyy")</p>
Finding out if media has been updated
I'm creating a list that brings back a list of the recently updated pages on my site. When a page is created modified, it auto adds it to the list.
Now I'm wanting to do the same but to also include media as well.
How can I modify my code to allow this. I'm very new to umbraco still.
Hi SlothMonkey,
For the media you can use the built in code-snippet called List Images From Media Folder, then the user can pick a media folder in the media section, and then you loop through the images in this folder.
You can do it using a partial view macro, then when you add the macro to the template, and pick the folder in media section
For the Partial view macros, you need code like this, and add a paramerter to your macro. http://umbraco.tv/videos/implementor/working-with-umbraco-data/macros/setting-up-macro-parameters/ to see this video, it require that you have access to the Umbraco TV.
Partial view macro documentation can be found here: http://our.umbraco.org/documentation/Reference/Templating/Macros/Partial-View-Macros/
Hope this helps,
/Dennis
is working on a reply...