I need to get the Update Date of a media object and have not been able to do so, I have the following code that loops thru a media folder and works but I need the updateDate for each media item.
Thanks in advance for your help!
John
@using umbraco.cms.businesslogic.media;
@using uComponents.Core;
@using uComponents.Core.uQueryExtensions;
@using System
@{
// Set default media root node id
int rootNodeId = 1116;
// Try to get media id from macro parameter "mediaFolderNodeId" type "mediacurrent"
Int32.TryParse(Parameter.source, out rootNodeId);
// Try to get media id from querystring
if (Request["OpenMediaFolderId"]!=null)
{
Int32.TryParse(Request["OpenMediaFolderId"], out rootNodeId);
}
// Get media node and iterate the children
var m = new Media(rootNodeId);
<table class="info-table">
<tr><th>Toolkit:</th><th>Updated On:</th>
@foreach (var c in m.GetChildMedia())
{
if( c.GetPropertyAsString("Category") == @Parameter.category ) {
<tr>
<td><a href="@c.GetPropertyAsString("Filename")">@c.GetPropertyAsString("Description")</a></td>
</tr>
}
}
</table>
}
Your using Razor syntax but you're not really using any of the new dynamic node classes that were introduced with Razor that make dealing with this kind of thing easier. Presuming you are using Umbraco 4.7.1 then you can do this to get a quick list of items in a media folder and their Update Date:
dynamic folder = Library.MediaById(1234);
if (folder.NodeTypeAlias == "Folder")
{
<ul>
@foreach (var media in folder.Children)
{
<li>
@media.Name - @media.UpdateDate
</li>
}
</ul>
}
Using dynamic types make it much cleaner and you need less code. I'm sure you can adapt this to your needs.
Getting updateDate of Media object
Hi All,
I need to get the Update Date of a media object and have not been able to do so, I have the following code that loops thru a media folder and works but I need the updateDate for each media item.
Thanks in advance for your help!
John
Your using Razor syntax but you're not really using any of the new dynamic node classes that were introduced with Razor that make dealing with this kind of thing easier. Presuming you are using Umbraco 4.7.1 then you can do this to get a quick list of items in a media folder and their Update Date:
Using dynamic types make it much cleaner and you need less code. I'm sure you can adapt this to your needs.
Dan,
Thanks so much, that did it. Time for me to read up on the Dynamic Node stuff. Adios XSLT!
John
is working on a reply...