Templates

Created by Webnodes

Every content in Webnodes can be associated with a template. You specify the template in the options tab in the UI or the "ContentBase.TemplateId" property in code. The TemplateId is simply the Node Id of the actual template. 

Each template is restricted to a set of content classes, this is defined in the Template module. If only one template is associated with the content class of a new content instance, then the template Id will be set automatically on the new content. You can also set the default template for each class in the Ontology module, under the class settings. The setting is called "Default Template Id". 

Each template is associated with a stylesheet. This association is use to specify which stylesheet should be used by the HTML editor when a user is editing a content. The system will look at the template the content is using and at the stylesheet the template is associated with. It will then inject the styles found in this stylesheet into the HTML editor. You are not required to set up the association, but it will help to make the appearance of content in the HTML editor to match the appearance of content rendered in the page view.

There is built-in functionality for handling mobile devices and switching templates based on user agents in the http header. Se here for more information about mobile templates

There are two types of templates in Webnodes:

Webform templates

Webform templates simply point to a file on the server and normally an ".aspx" file. See here for more details

MVC templates

MVC templates are different and refer to MVC Routes. With MVC, the url rewrite is left to the MVC framework. The MVC template in webnodes simply defines which route is associated with a content and specifies how Webnodes should construct the URL of a content, and how Webnodes should associate a request to a Webnodes content. See here for more details

Mixing templates systems

You can mix both webform templates and MVC type templates in the same website. If a request both match the address of a content refering to a webform template and the request match an MVC route, the webform template will take precedence. If no request match any routes associated with webnodes, nor any content associated with webforms, it will simply let the request through leave it up the ASP.Net framework to handle it. So not only can you mix MVC templates with webform templates, but you can also mix a Webnodes website with independant .aspx files or MVC routes and controllers that has nothing to do with Webnodes.