[C#]
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: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?delete_linked_document.htm