Create document

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

Creating a new document

 

[C#]

 

string newsName = "My first news";

// create tree provider instance

CMS.TreeEngine.TreeProvider provider = new CMS.TreeEngine.TreeProvider(CMS.CMSHelper.CMSContext.CurrentUser);

 

// get parent node for new document

CMS.TreeEngine.TreeNode parent = provider.SelectSingleNode(CMS.CMSHelper.CMSContext.CurrentSiteName, "/News", "en-us");

 

// create a new tree node

CMS.TreeEngine.TreeNode node = new CMS.TreeEngine.TreeNode("cms.news", provider);

 

if (parent != null)

{

  // set document properties

   node.NodeName = newsName;

   node.NodeAlias = newsName;

   node.SetValue("DocumentCulture", "en-us");

   node.SetValue("NewsTitle", newsName);

   node.SetValue("NewsSummary", "Some summary.");

   node.SetValue("NewsText", "Some text.");

   node.SetValue("NewsReleaseDate", DateTime.Now);

  // create New document

   node.Insert(parent.NodeID);

}

 

Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?creating_documents.htm