Naming conventions

When working with MVC-based widgets and templates, you create and manage files of specific types and store them in a specific location in your project. You follow naming conventions that define how Sitefinity CMS prioritizes and resolves views and assets like scripts, for example.

Designer views

The following table summarizes how you name your files and where you store them:

File type Convention Location of file Description 

Designer view

For example, you are creating a designer view, named Custom, for a News widget. 

DesignerView.Custom.cshtml ~/MVC/Views/News/Custom 

A template for the custom view in the widget designer.

Designer view for dynamic content widget DesignerView.Custom.cshtml ~/Mvc/Views/<DynamicContentTypeName>/Custom 

A template for the custom view of a dynamic content type widget. <DynamicContentTypeName> is the name of the dynamic content type, for example Country. If you created a dynamic type with name Countries, the folder name must still be named with singular form.

JSON configuration  DesignerView.Custom.json  ~/MVC/Views/News/Custom 

JSON file that defines a set of additional scripts (and their dependencies),  required by the designer view, to be rendered.

Has the same name as the view template.

Script  designerview-custom.js

~/MVC/Scripts/News/Custom

designerview-custom.js containing AngularJS controller named CustomCtrl

A JavaScript file with custom client-side logic. Needs to be in the same location as the custom view, so that it overrides the default script file. 
Angular controller CustomCtrl The controller that handles the populating and saving of widget properties through the designer.

In addition, Sitefinity CMS follows a strict convention for resolving views for widgets, based on where the view files are located. For details, see Priorities for resolving views.

Frontend views

The following table summarizes the naming conventions of frontend views of MVC widget types.

Widget type Convention Location of file Description

Widgets  with List and Detail views:

  • Blog
  • Blog post
  • Document
  • Event
  • Event Scheduler
  • Image gallery
  • Lists
  • News
  • Users list
  • Video gallery

This list also includes any dynamic content widget.

List.ViewName.cshtml ~/Mvc/Views/ControllerName
~/Mvc/Views/<DynamicContentTypeName>

You need to use the view name.

When working with dynamic content widgets, the name of the folder must correspond to the name of the content type.

 

Detail.ViewName.cshtml
  • Account activation
  • Card
  • Change password
  • Comments
  • Comments count
  • Feed
  • Flat taxonomy
  • Form
  • Hierarchical taxonomy
  • Language selector
  • Login form
  • Login status
  • Navigation
  • Registration
  • Reviews
  • Reviews count
  • Site selector
  • Subscribe form
  • Unsubscribe form
  • Video
NavigationView.Horizontal.cshtml ~/Mvc/Views/ControllerName

In the example, Horizontal is a unique template name that will be displayed in the Templates dropdown menu. You can replace the name with one that suits your needs.

The custom view must be placed in a folder that corresponds to the controller name (without the Controller suffix).

IMPORTANT: You need to have the NavigationView in the beginning of your view name, so that the template is associated with the Navigation widget.

  • Breadcrumb
  • Content pager
  • Document link
  • Image
  • Search box
  • Search results
Breadcrumb.cshtml ~/Mvc/Views/ControllerName
You can name the view .cshtml file according to your preferences.
  • Captcha
  • Checkboxes
  • Dropdown list
  • File field
  • Hidden field
  • Navigation field
  • Multiple choice
  • Page break
  • Paragraph text
  • Section header
  • Submit button
  • Text field

Write.<NameOfTemplate>.cshtml

Read.<NameOfTemplate>.cshtml

~/Mvc/Views/<NameOfWidget>

Substitute <NameOfTemplate> with a name of your choice.

Most of these fields are dropped in form editor and are therefore referred to as form fields.

IMPORTANT: The form editor is package agnostic, you need to place the new widget templates in the root of your project ~/Mvc/Views/<NameOfWidget>

Content block Default.cshtml
~/Mvc/Views/ControllerName The Content block has specifics that require the name of the file to be Default, because the ContentBlockController renders a view named Default.

Tags

Was this article helpful?