I need to get a ContentType object by ID, on umbraco v4 I used to do it using the DocumentType object, it was pretty easy, looks like with ContentType now it's really a mess, but maybe I'm just doing it the wrong way?
Basically I needed to create 4(!!!) objects just to be able to use the method GetContentType, it would be much easier to just have a static method...
Anyone know a better way to do it? Below my code.
Thanks!
//get content type.. a lot of stuff... any way to do it faster/better?
ContentService cs = new ContentService();
RepositoryFactory rf = new RepositoryFactory();
MediaService ms = new MediaService(rf);
ContentTypeService cts = new ContentTypeService(cs, ms);
ContentType ct = (ContentType)cts.GetContentType(123456);
I just ran into this exact problem on my search page. I wanted to display the document type's name on the website. Not the sexiest code, but thanks Joao, this helped me!
umbraco v6 - get content type by ID, easier way?
Hello,
I need to get a ContentType object by ID, on umbraco v4 I used to do it using the DocumentType object, it was pretty easy, looks like with ContentType now it's really a mess, but maybe I'm just doing it the wrong way?
Basically I needed to create 4(!!!) objects just to be able to use the method GetContentType, it would be much easier to just have a static method...
Anyone know a better way to do it? Below my code.
Thanks!
I just ran into this exact problem on my search page. I wanted to display the document type's name on the website. Not the sexiest code, but thanks Joao, this helped me!
I guess this will help
is working on a reply...