Within N2 CMS, is there a way to programmatically remove nodes from the trash?
Asked
Active
Viewed 324 times
0
-
please show some source code... what have you tried ? what exactly is not working ? – Yahia Dec 15 '12 at 21:26
-
according to source code there a possibility to do a `Restore` for items in the trash. – Yahia Dec 15 '12 at 21:35
-
Not looking to restore. Looking to remove / delete from trash. – Tron5000 Dec 16 '12 at 09:50
-
You can purge the items contained in the trash. – Yahia Dec 16 '12 at 10:02
1 Answers
0
I figured it out. In this example models of type TargetDetailModel are being permanently deleted from the N2 CMS trash.
var trash = new ItemList<TrashContainerItem>(N2.Find.RootItem.Children, new TypeFilter(typeof(TrashContainerItem))).FirstOrDefault();
if (trash != null)
{
var detailToPermDelete = new ItemList<TargetDetailModel>(trash.Children, new TypeFilter(typeof(TargetDetailModel)));
for (int permDeleteCount = 0; permDeleteCount < detailToPermDelete.Count; permDeleteCount++)
{
N2.Context.Current.Persister.Delete(detailToPermDelete.ElementAt(permDeleteCount));
}
}

Tron5000
- 844
- 11
- 24