Sites

Contents

Sites add support for building building pages, in addition to form-based content.

For a hands on introduction to sites and the concepts described here, visit the My first site tutorial.

Introduction

Sites unlock powerful functionality for managing websites and creating visually oriented content like pages, page templates and fragments.

Similar to content projects, you may add applications to a site. For sites however, purpose-specific applications like sitemap.xml, robots.txt, Google Analytics, SEO Metafields, and Siteimprove introduce features and management capabilities beyond that of basic content.

Site content type

Site is a built-in content type, which means a site can easily be created anywhere in your content structure.

Site content items are special in the way that you may add applications to them. Similar to projects, functionality and schemas from the app will be available in the scope of the site.

Apps added to a project will not apply to a site, unless explicitly added there as well.

The site engine

When rendering sites and pages with the Enonic framework, request handling and resolving is performed by the site engine. It offers site-specific capabilities and request handling such as:

site.xml

Applications declare support for sites by including the site.xml descriptor file.

This descriptor serves multiple purposes:

  • Declares that this app supports sites (and CMS projects)

  • Defines a form that lets you configure the application on a per site (or project) basis

  • Define X-data mappings

  • Define controller and filter mappings.

  • Define response processors.

The descriptor must be placed in your app as: src/main/resources/site/site.xml

Minimal site.xml example
<site>
  <form/>
</site>
Site.xml with all options in use
<site>
  <form>  (1)
    <input type="TextLine" name="company">
      <label>Company</label>
      <occurrences minimum="1" maximum="1"/>
    </input>
    <mixin name="address"/>
  </form>
  <x-data name="seo-settings"/>  (2)
  <mappings>  (3)
    <mapping controller="/site/foobar/api.js" order="10">
      <pattern>/api/v\d+/.*</pattern>
    </mapping>
    <mapping controller="/site/pages/default/default.js">
      <match>type:'portal:fragment'</match>
    </mapping>
  </mappings>
  <processors>
    <response-processor name="tracker" order="10"/> (4) (5)
  </processors>
</site>
1 Define a form for this app. The form is used to create site specific configuration for the app.
2 Specify X-data fields to use within the site scope.
3 Controller and filter mappings definitions
4 Commonly used to add page contributions to the response
5 The order is used to decide execution order if multiple applications and processors are added to a single site.

Contents

Contents