Search block templates
Describes the ICustomViewLocation interface in Optimizely Forms.
Note
Optimizely Forms is only supported by MVC-based websites and HTML5-compliant browsers.
The ICustomViewLocation
interface provides paths for searching element block views.
These interface implementations return an array of paths. These paths are used by Forms.Core
to look up view template for Blocks
.
CustomViewLocationBase
is a base implementation (in Forms.UI
) for this interface, and FormsViewLocation
is the default implementation in Forms.
/// <summary>
/// Default element block view location paths.
/// </summary>
[ServiceConfiguration(typeof (ICustomViewLocation))]
public class FormsViewLocation: CustomViewLocationBase {
public override int Order {
get {
return 1000;
}
set {}
}
public override string[] Paths {
get {
return new string[] {
EPiServerFormsSection.Instance.FormElementViewsFolder, GetDefaultViewLocation()
};
}
}
}
Suppose the Forms.Samples project has this class. Forms.Core
looks for Element
template in ~/Views/Samples/ElementBlocks
and the default view location of the Samples add-on (in ~\\modules\\\_protected\\EPiServer.Forms.Samples\\Views\\ElementBlocks
).
[ServiceConfiguration(typeof (ICustomViewLocation))]
public class FormsSamplesViewLocation: CustomViewLocationBase {
/// <summary>
/// This will be loaded before path of Form.Core
/// </summary>
public override int Order {
get {
return 500;
}
set {}
}
public override string[] Paths {
get {
return new string[] {
"~/Views/Samples/ElementBlocks",
GetDefaultViewLocation()
};
}
}
}
Updated 9 months ago