Copied to clipboard

Flag this post as spam?

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


  • Helen Proudlove 6 posts 28 karma points
    Oct 22, 2010 @ 16:49
    Helen Proudlove
    0

    Getting media node properties

    I've managed to use Umbraco Examine to index pdfs in the media section, and I'm creating a user control to display the results. 

    I can get the search results back however I'm struggling to get all the information about the pdfs to display to the user.  I want to display the "name" property of the media node as defined in the CMS.  It should be simple as I've got the nodeid.  This is what I've tried so far.

    1.  Using the node factory to get the node by id, eg Node n = new Node(id).  The name property of the node object was an empty string and when I iterated through all the properties there was one which said "there are no published nodes with this id" (or words to that effect).  This id was definitely the id of an item in the media section.  Does this mean you can't get media nodes using the node factory?

    2. Using the umbraco.cms.businesslogic.media.Media class.  Here I can get the url of the media file but I can't get the name

    Does anyone have any ideas about how I can get the name of the media item?  I'm using umbraco v4.5.

    thanks

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Oct 22, 2010 @ 16:54
    Tom Fulton
    0

    To get the media (node) name, you should be able to use #2 and use the .Text property.

    Shorthand example:

    Media m = new Media(xxxx);

    string mediaName = m.Text;

     

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Oct 22, 2010 @ 17:05
    Jeroen Breuer
    0

    The easiest way to get all properties of a media item is to use umbraco.library.GetMedia(mediaId, false).

    Jeroen

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Oct 22, 2010 @ 17:42
    Jan Skovgaard
    0

    Hi Jeroen,

    Would'nt GetMedia(mediaId,false), atcually return true?...Shouldn't it be GetMedia(mediaId, 1) ? (1 = true, 0 = false)

    /Jan

  • Jacob Distel 8 posts 28 karma points
    Jul 27, 2011 @ 16:33
    Jacob Distel
    0

    Hi Helen,

    I'm trying to do the exact same thing you've done, index PDF files in the Media section with Examine and display the file name in the search results. Would it be possible for you to let me know how you've done that?

    A third party built our web site using Umbraco and Examine for the search functionality, but it's all new to me and I’m having a tough time figuring it out.

    Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft