How to get the documentType of a Document node via APi
hey guys,
i'm programming on the backend of umbraco...
i have the following code: I want to know the DocumentType of my countryHome Document. I've tried several things but i cannot find how to get it as a string..
var current = uQuery.GetDocument(pageId); //PageId is from current.Context.request['id']
var ancestors = uQuery.GetDocumentsByCsv(current.Path); //get all ancestors from the path and put them in List<Document>> if (ancestors.Count > 0) { Document countryHome = ancestors[0]; }
Fantastic Hendy.. thats works like a charm.. and yes getting the ancestors via path csv is really fast... i just stumbled upon it when looking through the uquery methods... It even omits the -1 node (content node).. so the first u get is the root node of the particular currentNode.. so its nice..
How to get the documentType of a Document node via APi
hey guys,
i'm programming on the backend of umbraco...
i have the following code: I want to know the DocumentType of my countryHome Document. I've tried several things but i cannot find how to get it as a string..
ANy help is appreciated. Thanks in advance..
Hi Wiske80,
Had never thought of getting ancestors via the path csv ! (possibly slightly quicker than recursing up the tree with the .GetAncestorDocuments())
You could either cast the Document to a Node and use the .NodeTypeAlias property, or:
HTH,
Hendy
Fantastic Hendy.. thats works like a charm.. and yes getting the ancestors via path csv is really fast... i just stumbled upon it when looking through the uquery methods... It even omits the -1 node (content node).. so the first u get is the root node of the particular currentNode.. so its nice..
is working on a reply...