Kentico CMS 6.0 Developer's Guide

Sample document structure

Sample document structure

Previous topic Next topic Mail us feedback on this topic!  

Sample document structure

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

Arrow


API examples for newer versions


Please visit the latest API Examples documentation to view API examples for newer versions of Kentico.



The following example is not directly related to document attachments. It only creates a sample document to which attachments will be added and managed by the code examples in the following topic.

 

private bool CreateExampleDocument()

{

  // Create a new instance of the Tree provider

  TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

 

  // Get site root node

  TreeNode parentNode = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/", "en-us");

 

  if (parentNode != null)

   {

      // Create the document

      TreeNode node = TreeNode.New("CMS.MenuItem", tree);

 

       node.DocumentName = "API Example";

       node.DocumentCulture = "en-us";

 

       node.Insert(parentNode);

 

      return true;

   }

 

  return false;

}

 

The following example deletes the sample document created by the code example above.

 

private bool CreateExampleDocument()

{

  // Create a new instance of the Tree provider

  TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

 

  // Get site root node

  TreeNode parentNode = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/", "en-us");

 

  if (parentNode != null)

   {

      // Create the document

      TreeNode node = TreeNode.New("CMS.MenuItem", tree);

 

       node.DocumentName = "API Example";

       node.DocumentCulture = "en-us";

 

       node.Insert(parentNode);

 

      return true;

   }

 

  return false;

}