Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jim Mauch 4 posts 24 karma points
    Apr 23, 2013 @ 19:09
    Jim Mauch
    0

    Media File object: How to reference 'Last edited' property

    Hi all, I have this code where I can access most properties, just cant figure out 'Last Edited' property (and some others)...TIA!!!

    @foreach(umbraco.cms.businesslogic.media.Media m in startMedia.GetChildMedia())
    {

    string fileUrl = m.getProperty("umbracoFile").Value.ToString();
    string imageUrl = m.getProperty("umbracoExtension").Value.ToString();

    .... misc code....


    <li>
    <img src=@imageUrl />
    <a href=@fileUrl>@m.Text</a>
    @Html.Raw(m.getProperty("description").Value)
    @m.Id
    </li>

    I successfully access the umbracoFile, UmbracoExtension, description (a custom property), Id and Text properties. How does one reference the 'Last Edited' property associated w/ a Media object of type 'Media File'? I've tried 'LastEdited', 'LastEdit, 'lastedit, etc...

    Maybe a better question is where to find out how umbraco maps properties to the backoffice UI. i.e. A Media File type displays 'Name' on the backoffice, but is referenced in code as 'Text'. And I can't figure out 'Created', 'Created By' either.

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 23, 2013 @ 22:05
    Tom Fulton
    0

    Hi Jim,

    Welcome to our!

    I think you can use the following:

    • Last Updated: m.VersionDate
    • Created By: m.User.Name
    • Created: m.CreateDateTime

    To answer your question, there isn't really a set way it maps those "special" properties on the Properties tab.  Your best bet in the future is to look in the autocomplete if you're using VS, and ultimately the source code.

    Hope that helps,
    Tom 

  • Jim Mauch 4 posts 24 karma points
    Apr 23, 2013 @ 22:19
    Jim Mauch
    0

    Tom, u da' man! Thanks for taking a look at that.

    IMHO I find it really confusing why the backoffice UI and the underlying datasource (so to speak...) can't use the same verbage. I am sure I dont know umbraco well enough, but can't the UI just display 'VersionDate' instead of 'Last Edited'? (perhaps a rhetorical question!!!)

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 23, 2013 @ 22:23
    Tom Fulton
    0

    Yeah, its because Media and other APIs are pretty old and weren't always developed with a lot of consistency.

    The good news is, v6 includes new APIs that are documented and use much more standards.  For an example have a look at the documentation for the new Media object.  You can clearly see UpdateDate, CreateDate, CreatorId, etc - and the same are in use on the Content object.  

    I think I just assumed you were using an older version, but if not, you can take advantage of these new APIs if you like :)

  • Jim Mauch 4 posts 24 karma points
    Apr 24, 2013 @ 17:58
    Jim Mauch
    0

    Thanks for the info Tom, Last question plz: I still didnt see how you found out 'Last Updated:' related to 'm.VersionDate'. How did you find that out? I'm assuming either VS autocomplete or the source code (what exactly did you mean by source code?)  Thanks again!!

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 24, 2013 @ 18:03
    Tom Fulton
    0

    Yeah, I took a quick look at the source of the editMedia.aspx page :)

    Also just noticed you're in Denver - hit me up on twitter or me at tomfulton.net if you're ever interested in grabbing a beer and talking Umbraco - we're hoping to get a group going here someday.

  • Jim Mauch 4 posts 24 karma points
    Apr 24, 2013 @ 18:15
    Jim Mauch
    0

    Beer? Did someone say beer? Sounds good. An Umbraco users group would be cool, count me in.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 24, 2013 @ 18:18
    Tom Fulton
    0

    Drop me an email with your info and let's get something going!  me at tomfulton.net

Please Sign in or register to post replies

Write your reply to:

Draft