Retreive the content editor language and item version
Here is a small tip to retreive the language and the version of the item selected in the sitecore content editor when you create a custom field for example.
public class MyCustomField : CustomDropListField
{
public string ItemLanguage { get; set; }
public string ItemVersion { get; set; }
}
Thank you to Mister Tony Locatelli from LBi Belgium for this tip :)
I think the entire list of properties you can expose for automatic setting is as follows (from Sitecore.Shell.Applications.ContentEditor.EditorFormatter):
thanks for the thank
ReplyDeleteAren't there also properties for the ID of the selected item as well as the ID of the field?
ReplyDeleteRemember to retrieve the item from Sitecore.Context.ContentDatabase if it is not null, Sitecore.Context.Database otherwise.
I think the entire list of properties you can expose for automatic setting is as follows (from Sitecore.Shell.Applications.ContentEditor.EditorFormatter):
ReplyDeleteReflectionUtil.SetProperty(editor, "ID", field.ControlID);
ReflectionUtil.SetProperty(editor, "ItemID", field.ItemField.Item.ID.ToString());
ReflectionUtil.SetProperty(editor, "ItemVersion", field.ItemField.Item.Version.ToString());
ReflectionUtil.SetProperty(editor, "ItemLanguage", field.ItemField.Item.Language.ToString());
ReflectionUtil.SetProperty(editor, "FieldID", field.ItemField.ID.ToString());
ReflectionUtil.SetProperty(editor, "Source", field.ItemField.Source);
ReflectionUtil.SetProperty(editor, "ReadOnly", readOnly);
ReflectionUtil.SetProperty(editor, "Disabled", readOnly);