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.
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.
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
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;
The easiest way to get all properties of a media item is to use umbraco.library.GetMedia(mediaId, false).
Jeroen
Hi Jeroen,
Would'nt GetMedia(mediaId,false), atcually return true?...Shouldn't it be GetMedia(mediaId, 1) ? (1 = true, 0 = false)
/Jan
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.
is working on a reply...