Force form edit view for content in Episerver

Force form edit view for content in Episerver

1 minuter

This code sample demonstrates how to force form editing for specific content types in Episerver, for scenarios where on-page editing isn't practical.

Migrerad artikel

Denna artikel har migrerats från en tidigare version av vår webbplats och kan därför avvika i utseende och funktionalitet.

Översättning saknas

Den här artikeln är inte översatt till svenska och visas därför på engelska istället.

One way of customizing how a content type behaves in Episerver is to use descriptors.

Let's say I have a block or page type called MyContentType. By adding the following class to my project I can make form editing, i.e. the "All Properties" view, the default for whenever content of type MyContentType is edited:

[UIDescriptorRegistration]
public class MyContentTypeDescriptor : UIDescriptor<MyContentType>
{
    public MyContentTypeDescriptor() : base("dijitIcon")
    {
        // Make form editing the default for this content type
        DefaultView = CmsViewNames.AllPropertiesView;
    }
}

Descriptors can be used for a wide variety of customizations, for example to change the icon used to represent the content type in the page tree, media pane, etc:

[UIDescriptorRegistration]
public class MyContentTypeDescriptor : UIDescriptor<MyContentType>
{
    public MyContentTypeDescriptor() : base("dijitIcon")
    {
        // Change icons, based on available icons at http://ux.episerver.com
        IconClass = $"{IconClass} epi-iconProduct".Trim();
    }
}
Senast uppdaterad: 2017-04-18