How to Add Item in Sitecore

2015/5/11 min read
bookmark this
Responsive image

How to add item in C# code


 using (new Sitecore.SecurityModel.SecurityDisabler())
                {
                    var database = Sitecore.Configuration.Factory.GetDatabase("Master or Web");
                    TemplateItem template = database.GetItem("Your Page Item's page template url");
                    Item item = database.GetItem("where do you want to add the item");
                    Item newItem = item.Add("New Item name", template);
                    newItem.Editing.BeginEdit();
                    addItem(newItem);
                    newItem.Editing.EndEdit();
                    return newItem;
                }