Kentico CMS 6.0 Developer's Guide

Organizing documents

Organizing documents

Previous topic Next topic Mail us feedback on this topic!  

Organizing documents

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 moves Document 2 created by the code example in the Sample document structure topic up in the content tree.

 

private bool MoveDocumentUp()

{

  // Create an instance of the Tree provider

  TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

 

  // Select a node

  TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example/Document-2", "en-us");

 

  if (node != null)

   {

      // Move the node up

       tree.MoveNodeUp(node.NodeID);

 

      return true;

   }

 

  return false;

}

 

The following example moves Document 1 created by the code example in the Sample document structure topic down in the content tree.

 

private bool MoveDocumentDown()

{

  // Create an instance of the Tree provider

  TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

 

  // Select a node

  TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example/Document-1", "en-us");

 

  if (node != null)

   {

      // Move the node up

       tree.MoveNodeDown(node.NodeID);

 

      return true;

   }

 

  return false;

}

 

The following example sorts documents created by the code example in the Sample document structure topic alphabetically.

 

private bool SortDocumentsAlphabetically()

{

  // Create an instance of the Tree provider

  TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

 

  // Select a node

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

 

  if (node != null)

   {

      // Sort its child nodes alphabetically - ascending

       tree.OrderNodesAlphabetically(node.NodeID, true);

 

      return true;

   }

 

  return false;

}

 

The following example sorts documents created by the code example in the Sample document structure topic by date and time of creation from the oldest to the newest.

 

private bool SortDocumentsByDate()

{

  // Create an instance of the Tree provider

  TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

 

  // Select a node

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

 

  if (node != null)

   {

      // Sort its child nodes by date - descending

       tree.OrderNodesByDate(node.NodeID, false);

 

      return true;

   }

 

  return false;

}