Skip to content

Instantly share code, notes, and snippets.

View drift's full-sized avatar

Justin Moore drift

View GitHub Profile
@drift
drift / UmbracoChangeDocType
Created July 10, 2013 14:33
Umbraco v6 change document type of a node
@using Umbraco.Core.Models;
@using Umbraco.Core.Services;
var contentService = ApplicationContext.Current.Services.ContentService;
var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
var contentType = contentTypeService.GetContentType(4200);
var content = contentService.GetById(2052);
content.ChangeContentType(contentType);
contentService.Save(content);
@drift
drift / UmbracoChangeDocTypeParent
Created July 10, 2013 14:34
Umbraco v6 Change DocumentTypes Parent
@using Umbraco.Core.Models;
@using Umbraco.Core.Services;
var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
var contentType = contentTypeService.GetContentType(4200);
contentType.ParentId=3130;
contentTypeService.Save(contentType);
@drift
drift / Umbv6ChangeTemplate
Last active December 19, 2015 18:39
Umbraco v6 change templates
var contentService = ApplicationContext.Current.Services.ContentService;
var content = contentService.GetById(1538);
//quick change lots of nodes template
var fileService = ApplicationContext.Current.Services.FileService;
var template = fileService.GetTemplate("CJ-Content");
foreach(var item in content.Children())
{
item.Template = template;
contentService.Save(item);