Episerver Forms has ICustomViewLocation, used for searching custom block templates

This interface provides paths for searching element block views.

  • These interface’s implementations will return an array of paths.
  • These paths will be used by Forms Core to lookup view template for Blocks.
  • FormsViewLocationBase is a base implementation for this Interface
  • and FormsViewLocation is default implementation in Form Core
  • Paths have been ordered. The default builtin path’s order is 1000
[ServiceConfiguration(typeof(ICustomViewLocation))]
public class FormsViewLocation : FormsViewLocationBase
{
public override int Order { get { return 1000; } set {} }
public override string[] Paths
{
get{
return new string[] { EPiServerFormsSection.Instance.FormElementViewsFolder, GetDefaultViewLocation() };
}
}
}

Let says Forms.Samples project has this class. FormCore will look for Element template in ~\modules\_protected\EPiServer.Forms.Samples\Views\ElementBlocks(of Samples module), then ~/Views/Samples/ElementBlocks (default location)

[ServiceConfiguration(typeof(ICustomViewLocation))]
public class FormsSamplesViewLocation : FormsViewLocationBase
{
/// <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() };
}
}
}
Show your support

Clapping shows how much you appreciated lockevn’s story.