HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In
GitHubNuGetDev CommunityDoc feedback

If you want further control over how the user interface is rendered, you can add an editor template for your class by creating a partial MVC view, and name the view as your model, such as _{nameOfMyModelClass}.ascx_. The application can look for the view in two places:

  • If your criterion is part of a registered module, the first search path is: _{yourModuleRoot}/Views/Shared/EditorTemplates/{nameOfMyModelClass}.ascx_

  • If the view is not found in the module folder or if your criterion is not part of a module, the next search path is: _~/Views/Shared/EditorTemplates/{nameOfYourModelClass}.ascx_

In your editor template, you can import the `EPiServer.Personalization.VisitorGroups` to the `DojoEditorFor` method. The `DojoEditorFor` method creates a widget that handles loading and saving of values from/to a specified model class property. `DojoWidgetFor` discovers and makes use of any `DojoWidget` attribute settings for model class properties. If you do not use `DojoWidgetFor` to create edit controls for your properties, you need to handle the loading and saving of values yourself.

The following editor template shows an example using the `DojoWidgetFor` method, where two different overloads are used. The first call only specifies the name of the model class attribute; the second call uses the overload with the most number of parameters. A full range of overload exists between these two extremes.

## Custom script

The `VisitorGroupCriterion` attribute has a `ScriptUrl` property, where you can specify a script file that is used when creating the settings user interface. The `ScriptUrl` should contain a JavaScript object that overrides one or more of the following methods:

  • `createUI()` – Called to create the user interface for the criterion.

  • `validate` – Called when the user tries to save a visitor group.

  • `getSettings` – Called when the visitor group is saved to gather the data to save.

  • `uiCreated` – An event that is raised when the user interface has been created.

The following script shows an example where these methods are overridden: