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.
Following is a list of the different ways to resolve views for widgets. The list is ordered by priority from highest to lower:
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/.
After the 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 ~/MVC/Views/ContentBlock/[ViewName].[extension]
The extension of the template file depends on your view engine. For Razor the extension is .cshtml, for WebForms the extension is .aspx.
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.
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: ~/Frontend-Assembly/[Assembly-Name]/[Path]
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, ~/Frontend-Assembly/Telerik.Sitefinity.Frontend/Mvc/Scripts/Angular/angular.min.js
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.
Back To Top
Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.