Layouts, Models and Namespaces


The structure of the view layer derives from the page types and components available in the CMS site. In most cases, there should be a view in the MVC solution for each page type in the CMS. Many components also have corresponding views.

When you create a new view, you'll need to include the appropriate model, namespaces, and layout.

Layouts

By default, new views use the layout indicated in the _ViewStart file. To specify a different layout, change the layout file indicated in "~/Views/Shared/_Layout.cshtml". For example, the following statement sets a view to use _SectionLayout.

_SectionLayout
@ {        
   Layout = "~/Views/Shared/_SectionLayout.cshtml";
}

Models & Namespaces

The namespaces and model for a view depend on what the view does. A view that renders a relatively simple page type might use Ingeniux.Runtime.ICMSPage as a model and Ingeniux.Runtime as a namespace.

Ingeniux.Runtime.ICMSPage
@model Ingeniux.Runtime.ICMSPage
@using Ingeniux.Runtime

A view for rendering a navigation component might use the ICMSLinkElement interface as a model.

ICMSLinkElement
@model Ingeniux.Runtime.ICMSLinkElement
@using Ingeniux.Runtime;

A more complex view that needs to step through XML using LINQ to XML and XPath queries might require additional LINQ and XPath namespaces.

@model Ingeniux.Runtime.ICMSPage
@using Ingeniux.Runtime
@using System.Xml.Linq
@using System.Xml.XPath

Next Steps: Render XML Content.