Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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()
I hope this can help you.
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.
var content = Services.ContentService.GetById(sr.Id);
var docName = content.ContentType.Name;
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.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted