I am building a custom Field in sitecore 6.5. This field will generate new items based on the item in which the field resides (it uses the item’s name to generate folders) and I need to reference the item in which the field is being used. How do I get access to this?
My custom field inherits from the sitecore Sitecore.Shell.Applications.ContentEditor.File class, if that helps at all.
My question is similar to the one located here: How to get a reference to the currently edited item when inside a custom field in Sitecore
However, the question there was for a previous version of sitecore, and the solutions no longer seem to work (ItemID is not in the viewstate, nor is it filled by the pipeline).
Thank you!
If i’m not mistaken,
Sitecore.Data.Fields.FileFieldis a representation of the field’s data in the Sitecore API. For instance, you would use it to retrieve theMediaItemorSrcby casting an item’s field like so:I don’t think it’s intended to be used as a custom field in the Sitecore client. Try inheriting from
Sitecore.Shell.Applications.ContentEditor.Fileor just strait upSitecore.Web.UI.HtmlControls.Control. As long as you have apublic string ItemID { get; set; }property defined, Sitecore should populate it with the current item ID.