代码之家  ›  专栏  ›  技术社区  ›  Nick Allen

在Sitecore CMS中递归删除子项。网

  •  2
  • Nick Allen  · 技术社区  · 16 年前

    我的Sitecore媒体库中有以下结构

    图片/部门/子部门/产品/

    我想一次删除一个部门代码中的所有图像。目前我有

    Item[] items = database.SelectItems("/sitecore/media library/images/department1//*");            
    
    Sitecore.Data.Engines.DataEngine engine = new Sitecore.Data.Engines.DataEngine(database);
    
    using (new SecurityDisabler())
    {
        foreach (Item item in items)
        {
            engine.DeleteItem(item))
        }
    }
    

    1 回复  |  直到 16 年前
        1
  •  7
  •   Alexey Rusakov    16 年前

    同时删除所有子项很容易:

    项目部门1=数据库。GetItem(“/sitecore/媒体库/图像/部门1”); 部门1.删除儿童();

    这将保留部门1项,但该项下的所有内容都将被删除。