I'm looking (since about an hour) for an API reference of umbraco. I've been able to guess the media section (umbraco.cms.businesslogic.media) from a .NET usercontrol but, now I'm stuck for getting the content items.
If i add a macro parameter and pass a value of -1, which should be the root, I get an error. When I pass in the ID of a folder in the media section I can get the contents of that folder. I've never tried getting the root of the media folder so I'm not sure if I'm doing something wrong or if this is by design. BTW, I had to change one line from:
A value of -1 represents a "null" node. in other words, there is no node with an id of -1. Perhaps you could describe exactly what you are trying to achieve and post the code?
I was trying to select the root of the media section. I placed a Media Picker data type on my document type. When I selected the media section root and then saved/published, the value it saved was -1. Is there a way to get directly to the root of the media section with umbraco.library:GetMedia?
will give you the root node (named 'Content' when browsing in the cms).
I assume you're trying to locate something in the content tree - from the root node you can travel down the tree and find whatever you need by using for example:
Node n = new Node(-1).Children.OfType<Node>().Where(n => n.NodeTypeAlias == "SomeDocumentType").First()
So yeah it's basicly done a bit different than what you do with Media.GetRootMedias(), but it's the equivalent function for getting root content node...
When you create a new Media or Content object using new Media(-1) it looks in the database table umbracoNode. using -1 retrieves the Master Root Node for the Content object type. The first call to Children on the returned object queries the database for all nodes that have the Id as their parent. The Media type specifies it's own Object Type Id, so Children retrieve only Media items in this context.
however, the default umbraco.library.GetMedia() method returns an invalid node message in the XML because the Object Type Id of the Media item doesn't match what was retrieved from the database (which is a Content Object Type).
So with the current umbraco.library there is no way to get the Root Media items in Xslt. However, you could create your own Xslt extension library to expose the Media.GetRootMedias() method which will essentially do what you want...
Complete API Documentation
Hi everyone,
I'm looking (since about an hour) for an API reference of umbraco. I've been able to guess the media section (umbraco.cms.businesslogic.media) from a .NET usercontrol but, now I'm stuck for getting the content items.
Anyone have a suggestion ?
Thanks
Nico
Link to full API docs are in this thread -> http://our.umbraco.org/forum/developers/api-questions/13618-Where-did-the-API-documentation-go
And an example on the wiki for media -> http://our.umbraco.org/wiki/reference/code-snippets/listfilesfrommediafolderxslt/listing-files-from-a-media-folder-in-umbraco-45x-with-xslt
This looks helpful but, what gives me the basic path to the content items tree... Do I missed something ?
Anybody knows how to access to root element of the content section within aa ASP.NET usercontrol ?
Thanks in advance for your answers.
If i add a macro parameter and pass a value of -1, which should be the root, I get an error. When I pass in the ID of a folder in the media section I can get the contents of that folder. I've never tried getting the root of the media folder so I'm not sure if I'm doing something wrong or if this is by design. BTW, I had to change one line from:
to
The error I was getting was "No media is maching '-1'", which it looks like this will show up if an exception is thrown in the GetMedia method.
A value of -1 represents a "null" node. in other words, there is no node with an id of -1. Perhaps you could describe exactly what you are trying to achieve and post the code?
I was trying to select the root of the media section. I placed a Media Picker data type on my document type. When I selected the media section root and then saved/published, the value it saved was -1. Is there a way to get directly to the root of the media section with umbraco.library:GetMedia?
Hi,
For my case, I was talking about the C# API, something like Media m = Media.GetRoot(); (I don't have my code on sight right now).
Is there a documentation on this ? What class should I call to get the root of the Content section ?
Hi,
just to clarify, the exact call I'm looking for is like Media.GetRootMedias() but, for the Content tree.
Anybody has a suggestion ?
Well..
Node n = new Node(-1)
will give you the root node (named 'Content' when browsing in the cms).
I assume you're trying to locate something in the content tree - from the root node you can travel down the tree and find whatever you need by using for example:
Node n = new Node(-1).Children.OfType<Node>().Where(n => n.NodeTypeAlias == "SomeDocumentType").First()
So yeah it's basicly done a bit different than what you do with Media.GetRootMedias(), but it's the equivalent function for getting root content node...
This will work in a user control, but I'd still like to know if this can be done with umbraco.library in an XSLT file:
When you create a new Media or Content object using new Media(-1) it looks in the database table umbracoNode. using -1 retrieves the Master Root Node for the Content object type. The first call to Children on the returned object queries the database for all nodes that have the Id as their parent. The Media type specifies it's own Object Type Id, so Children retrieve only Media items in this context.
however, the default umbraco.library.GetMedia() method returns an invalid node message in the XML because the Object Type Id of the Media item doesn't match what was retrieved from the database (which is a Content Object Type).
So with the current umbraco.library there is no way to get the Root Media items in Xslt. However, you could create your own Xslt extension library to expose the Media.GetRootMedias() method which will essentially do what you want...
Hi,
this is what I was looking for. Thanks to everybody.
is working on a reply...