|
||
|
API examples for newer versions Please visit the latest API Examples documentation to view API examples for newer versions of Kentico. |
The following example creates a sample document structure that will be used by the API examples in the following topics.
private bool CreateDocumentStructure() { // Create an instance of the Tree provider TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
// First get the root node TreeNode parentNode = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/", "en-us");
if (parentNode != null) { // First create a folder TreeNode node = TreeNode.New("CMS.Folder", tree);
node.DocumentName = "API Example"; node.DocumentCulture = "en-us";
node.Insert(parentNode);
parentNode = node;
// Create a few documents for (int i = 1; i <= 3; i++) { node = TreeNode.New("CMS.MenuItem", tree);
node.DocumentName = "Document " + i; node.DocumentCulture = "en-us";
node.Insert(parentNode); }
return true; }
return false; } |
The following example deletes the sample document structure created by the code example above.
private bool DeleteDocumentStructure() { // Create an instance of the Tree provider TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
// Get the API Example folder TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example", "en-us");
// Delete the folder including all dependencies and child documents node.Delete();
return true; } |