Delete linked document

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



using CMS.SettingsProvider;

using CMS.CMSHelper;

using CMS.DataEngine;

using CMS.GlobalHelper;

using CMS.TreeEngine;

using CMS.SiteProvider;

using CMS.WorkflowEngine;




          // Prepare the TreeProvider

          // it must be initialized with user information when editing document structure

           UserInfo ui = UserInfoProvider.GetUserInfo("administrator");

           TreeProvider tree = new TreeProvider(ui);


          // Get the linked document by alias path (any culture)

           CMS.TreeEngine.TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/TestingNewsLink", TreeProvider.ALL_CULTURES, false, null, false);

          if (node != null)


              // Always delete the document with DocumentHelper

              // it handles all the dependencies

               DocumentHelper.DeleteDocument(node, tree, true, true, true);


              this.lblInfo.Text = "Link '" + node.NodeAliasPath + "' has been deleted.";



Page url: