How to change built in properties
If you want to change tab a built in property are placed in there are several ways of doing this. But one way is to make your self an Edit Panel plugin. If you implements ICustomPlugInLoader and always returns a empty array, there are no need for a ascx file.
- [GuiPlugIn(Area = PlugInArea.EditPanel)]
- public class ChangeBuiltInProperties : EPiServer.UserControlBase, ICustomPlugInLoader
- {
- public PlugInDescriptor[] List()
- {
- var editPanel = HttpContext.Current.Handler as EditPanel;
- if (null != editPanel)
- editPanel.LoadComplete += editPanel_LoadComplete;
- return new PlugInDescriptor[] { };
- }
You can then in the List() method hook up to the LoadCompleted event, and there get access hook up to the Populate event
- private void editPanel_LoadComplete(object sender, EventArgs e)
- {
- var dataForm = FindControl<PropertyDataForm>((Control)sender, null);
- if (dataForm != null)
- dataForm.Populate += new EventHandler(dataForm_Populate);
- }
You can then change the OwnerTab for a property.
- void dataForm_Populate(object sender, EventArgs e)
- {
- var dataForm = sender as PropertyDataForm;
- //todo: use PageTypeBuilder tabs
- var moveToTab=EPiServer.DataAbstraction.TabDefinition.Load("Information");
- var moveFromTab=EPiServer.DataAbstraction.TabDefinition.Load("Scheduling");
- foreach (var item in dataForm.Data)
- {
- if (item.OwnerTab == moveFromTab.ID)
- item.OwnerTab = moveToTab.ID;
- }
- }
- protected T FindControl<T>(Control control, string id) where T : Control
- {
- T controlTest = control as T;
- if (null != controlTest && (null == id || id.Equals(controlTest.ID)))
- return controlTest;
- foreach (Control c in control.Controls)
- {
- controlTest = FindControl<T>(c, id);
- if (null != controlTest)
- return controlTest;
- }
- return null;
- }
It’s also possible to change the built in property to another property type, but you have to create a new PropertyDataCollection and assign it to the Data property since that will change the collection.
That's pretty neat!
How do I make a built-in property like VisibleInMenu or SortOrder to be [CultureSpecific]??