Priorities for resolving views
Sitefinity CMS uses a strict convention for resolving the views for widgets. This article describes the different ways to add a view to a widget and what are the priorities for the different approaches.
Priorities for resolving views
Following is a list of the different ways to resolve views for widgets. The list is ordered by priority from highest to lower:
|Location of view
All resource packages, such as Bootstrap, Minimal, and so on, are located in this folder. For more information, see Overview: Resource packages.
The ResourcePackages folder is located in the root of the project: ~
ResourcePackages folder, Sitefinity CMS searches for your widget template in the
MVC folder, located in the SitefinityWebApp project. To match the views with their respective widget, when naming the views, you must follow the naming convention
The extension of the template file depends on your view engine. For Razor the extension is
.cshtml, for WebForms the extension is
|Widget templates section
MVC widget templates can be reused.
Sitefinity CMS first searches for your widget templates in the Design » Widget Templates section in the backend. By default, only templates of dynamic modules are automatically added on top the Widget templates section in the backend. You can create a custom widget template, as well, following the naming conventions. For more information, see Work with widget templates.
For example, the List.NewsList template is the list template of the News widget. If you have a file with List.NewsList name in [YourPackage]/MVC/Views/News folder, Sitefinity CMS loads the template from this folder. In case there is no such template in this location, Sitefinity CMS searches for a template with the same name in the Design » Page templates section in the backend. If there is no template with this name in this location, Sitefinity CMS gets the default template from the assemblies.
||By design, the MVC widgets that come out-of-the-box, such as Navigation, Content Block, or News, have corresponding assemblies that are referenced by the SitefinityWebApp. In each of the assemblies, the views have their Build action set to Embedded resource. This way all views are included in the assemblies. This is the final place where Sitefinity CMS searches to resolve the widget view.
Priorities for resolving assets
Telerik.Sitefinity.Frontend.FrontendService service registers a virtual path for each widget assembly and for
Telerik.Sitefinity.Frontend itself. The service also registers a route handler. This way, an
HTTP GET request to the same file returns it as a response:
The contents of a virtual file inside the
Frontend-Assembly path can come from the file system at location
~/[Path] When not found there, it falls back to retrieving the contents of an embedded resource placed on the same path, inside the specified assembly. For example,
If a file
~/Mvc/Scripts/Angular/angular.min.js exists, then it will be retrieved. Otherwise, the embedded resource
Telerik.Sitefinity.Frontend.Mvc.Scripts.Angular.angular.min.js is returned.