As part of a search filter I need to build a drop down list of document types. I can get the nodeTypeAlias easily, but how can I get the Name of the docType for a given nodeTypeAlias? Is there a library or namespace that exposes that?
Frist of all I am not a .NET developer, but I work as a frontend developer, so normally I work with Razor and XSLT, HTML, CSS and so on. But I will try to help you the best I can.
I found some documentation about documents, that I think could be interesting for you maybe. By using the .ContentType you should get the retuns of a .ContentType object representing the DocumentType used by the given Document.
The first link if for Umbraco version 6+ and use the ContentTypeService: There is a method called .GetContentType()
Thanks Dennis. You pointed me in the general direction. For Umbraco 6.x and7 it looks like the Document class has been replaced with the Content Class. This link gave the equivalent info.
As a note, I wouldn't recommend using the ContentService too much as it gets node data straight from the database which is far slower than getting it from the content cache (which is accessed using the UmbracoHelper).
You can also get the document/content type from the database this way:
var services = UmbracoContext.Application.Services;
var documentType = services .ContentTypeService.GetContentType(Model.Content.DocumentTypeId);
var docName = documentType.Name;
This method may not be faster than the one provided by Janet as it also gets data from the database, but it's likely that the document/content type table is smaller so theoretically it should be faster.
Get Document Type Name
As part of a search filter I need to build a drop down list of document types. I can get the nodeTypeAlias easily, but how can I get the Name of the docType for a given nodeTypeAlias? Is there a library or namespace that exposes that?
Hi Janet,
Frist of all I am not a .NET developer, but I work as a frontend developer, so normally I work with Razor and XSLT, HTML, CSS and so on. But I will try to help you the best I can.
I found some documentation about documents, that I think could be interesting for you maybe. By using the .ContentType you should get the retuns of a .ContentType object representing the DocumentType used by the given Document.
The first link if for Umbraco version 6+ and use the ContentTypeService: There is a method called .GetContentType()
http://our.umbraco.org/documentation/reference/Management-v6/Services/ContentTypeService#GetContentType%28stringalias%29
http://our.umbraco.org/documentation/Reference/management/Documents/document#ContentType
I hope this can help you.
/Dennis
Thanks Dennis. You pointed me in the general direction. For Umbraco 6.x and7 it looks like the Document class has been replaced with the Content Class. This link gave the equivalent info.
http://our.umbraco.org/documentation/Reference/Management-v6/Models/Content
As a note, I wouldn't recommend using the ContentService too much as it gets node data straight from the database which is far slower than getting it from the content cache (which is accessed using the UmbracoHelper).
You can also get the document/content type from the database this way:
This method may not be faster than the one provided by Janet as it also gets data from the database, but it's likely that the document/content type table is smaller so theoretically it should be faster.
is working on a reply...