sitecore publish item in C#

5/2/2015·2 min read

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;
                }