I’ve created a structure in Sitecore’s content tree as follows :
A Home root item, based on a template. Then I have a series of folders under the Home item, named by dates.
I’m creating a command template so that when I add a new item under the Home item, it automatically moves it under the folder represented by the current date.
However, the Item class’ MoveTo method only takes an Item as a parameter. So I have no idea how to tell it to move the Item into a Folder, as a Folder cannot be represented as an Item?
I’ve done some digging, and I’ve seen that when I place an item directly under the folder, it shows a different ParentID than if I put it directly under the Home item, implying that the Folder is indeed an Item. However, when I try to retrieve the Item represented by the Folder, I get null.
e.g. Sitecore.Context.Database.Items["/sitecore/content/Home/30Nov2011"];
Everything in Sitecore is an item (even folders), you can resolve the folder as an item based on its
pathorGUIDusing theDatabaseobject.Edit: As you are working in the content editor environment you will need to explicitly tell it which database to use (the
masterdatabase in this case) as theContextscope will not contain the database you are hoping to work with.Hope this helps.