Trying to create a ContentType with a class in a package. Does anyone know how this should be done?
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;
namespace MyProject
{
public class ContentTypeCreator
{
private readonly IContentTypeService _contentTypeService;
public ContentTypeCreator(IContentTypeService contentTypeService)
{
_contentTypeService = contentTypeService;
}
public void CreateContentType()
{
var ct = new ContentType(-1)
{
Alias = "MyContentType",
Name = "My Content Type",
Description = "This is my custom content type",
Icon = "icon-document"
};
_contentTypeService.Save(ct);
}
}
}
v10 c# create content type
Trying to create a ContentType with a class in a package. Does anyone know how this should be done?
Good article here
https://www.skrift.io/issues/working-with-content-types-and-data-types-programmatically/
Thank you for this!
is working on a reply...