Hide menu Last updated: Nov 02 2016
Area: Episerver Add-ons Applies to versions: 2 and higher

Searching block templates

Note: Episerver Forms is only supported by MVC-based websites and HTML5-compliant browsers.

This topic describes the CustomViewLocation interface in Episerver Forms. This interface provides paths for searching element block views.

How it works

These interface implementations return an array of paths. These paths are used by Forms Core to look up view template for Blocks.

Examples

FormsViewLocationBase is a base implementation for this interface, and FormsViewLocation is the default implementation in FormCore.

  /// <summary>
   /// Default element block view location paths.
   /// </summary>
   [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() };
           }
       }
   }

Suppose the Forms.Samples project has this class. FormCore 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 : 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() };
           }
       }
   }

Comments