Setting up a site

So you have installed one of the Relatude Nuget project templates, you have a working Relatude site on your local developer machine, and you are about to start your project. How do you start, and what is the process? Note that this article documents uses ASP.Net MVC as an example. A lot of the steps are the same with other technologies, but there are some differences.

Create the basic data model

The first order of busines is to define the data model you need for your project. Since Relatude supports custom relations between objects, you can basically create a data model like for any other development project, and then convert and create that model in the Ontology plugin in Relatude.

Usually we create a sketch of the data model. How you do that is up to you. If you do it on paper, in powepoint or in an application created for that purpose is your choice.  

When you create the data model in Relatude, you need to decide what built-in content class you want to extend for each of the classes you create:

Example from the Explore Norway demo site, showing how the FrontPage inherits from HierarchicalContent

 

Some of the most common built-in content classes to inherit from:

ContentBase is the base object that every node in the system is based upon. It is a very basic object that doesn't support the tree structure.

HierarchicalContent is another basic object, but that supports being added to the tree structure.

ProductBase is the basic product type for E-commerce. Products must inherit from this or ProductBundle.

Identify the templates you need

When you have created the basic data model, you should identify the templates you neeed. Usually you need one template for each content class that represents a page (a page can also be constructed by adding module nodes together as building blocks).  

Create controllers and views for the required templates

When you know the templates you need, you need to setup the ASP.Net MVC parts that will actually  handle the requests and render the response. One template is usually defined by a controller with an action that fetches the content and a view file that renders the output.

 

This is the most basic controller for fetching the content associated with the request and sending it to the view as the model:

The constructor gets the WAFNativeContent from Dependency Injection, and is required to access the context object. Request.GetContent fetches the content associated with the request.

The Razor file (the view) is done like this:

Notice the typed access to the properties on the content object (node), and the easy way to retrieve the scaled image that is automatically scaled to the size requested.

Creating the template nodes in Relatude

When you have created the content class and the controller and action, you need to setup the plumbing between Relatude and ASP.Net Core MVC. This is done by creating a node of type "MVC Template". Go to the settings module. Select the Templates

 

Create the basic content structure with the correct content classes