Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

module.config

Describes the <module> section of the module.config file, which is located in the root directory of a shell module and contains settings specific to that module.

The Configure CMS topic describes the syntax of the configuration elements.

<module>
  <assemblies/>
  <routes/>
  <clientResources/>
  <dojo/>
  <clientModule/>
</module>

<module>

<module helpFile="string"
        productName="string"
        clientResourceRelativePath="string"
        type="string">
  <assemblies/>
  <routes/>
  <clientResources/>
  <dojo/>
  <clientModule/>
</module>

<module> element attributes

NameDefault valueDescription
helpFile URL to the help file for this module. {culture}, {major}, {minor}, {build}, {revision} are replaced.
productName A product name for display. If this is not specified, the module name is used.
clientResourceRelativePath The client module resource relative path is combined with the resource base path and is used specifically for paths to client resources. If not defined, the resource base path is used as-is. One use for this is versioning the client resources in a module.
type The type specifies which class to instantiate for this module instance. If this is not set, ShellModule is used.
loadFromBintrueWhether to load all assemblies from the bin folder of the module. Otherwise, only assemblies listed under the assemblies element are loaded.
routeBasePathOptional base path for routes to the module. 
viewFolderOptional name of the folder containing views for the module. If not given, the expectation is that the views are in a folder named <moduleName>.Views.
authorizationPolicy"DefaultShellModulePolicy"Specifies which policy should be applied to the module. If not specified, a default policy that requires any of the roles WebEditors, WebAdmins, CmsAdmins, or Administrators is used.
moduleJsonSerializerTypeJsonSerializerType.ResolveSpecifies which JSON serializer the module should use. JsonSerializerType enum has the following values:

- Resolve – If the shell module contains any Newtonsoft JSON converter registered in DI container, Newtonsoft is used as serializer. Otherwise, the .Net Core built-in one is used.

- Newtonsoft – A Newtonsoft serializer is used.
- Net – The .Net Core built-in serializer is used.
- None – A Non-Specific serializer is registered for the module. This is useful, for example, if the module registers a custom serializer (such as Newtonsoft or the built-in serializer with custom settings) through code.
preferredUiJsonSerializerTypeJsonSerializerType.ResolveSpecifies which JSON serializer the CMS UI should use. This can be configured if the module is part of CMS UI serialization, for example, through custom types. JsonSerializerType enum has the following values:

- Resolve – If the shell module contains any Newtonsoft JSON converter registered in the DI container, Newtonsoft is used as a serializer. Otherwise, the .Net Core built-in one is used.

- Newtonsoft – A Newtonsoft serializer is used.
- Net – The .Net Core built-in serializer is used.
- None – None-specific serializer is registered for the module. Useful, for example, if the module registers a custom serializer (such as Newtonsoft or the built-in serializer with custom settings) through code.

<assemblies>

This list of assemblies specifies which assemblies belong to this shell module.

<assemblies>
  <add assembly="string" />
      ...
</assemblies>

<add> element attributes

NameDefault valueDescription
assembly Required. The name of an assembly that should be loaded and associated with the module.

<routes>

<routes>
      <route url="string"
             clientSideOnly="string"
             type="string"
             controllerPrefix="string">
        <defaults>
          <add key="string"
               value="string" />
          ...
        </defaults>
        <constraints>
          <add key="string"
               value="string" />
          ...
        </constraints>
        <dataTokens>
          <add key="string"
               value="string" />
          ...
        </dataTokens>
      </route>
      ...
</routes>

<route> element attributes

NameDefault valueDescription
url{moduleArea}/{controller}/{action}/{id}The URL pattern for the route. See the Route.Url property for details on how these values are used by the ASP.NET routing system. URL parameters are enclosed in braces ({}).
clientSideOnlyfalseDetermines whether this route only affects the client routing model.
type Fully-qualified name of class to instantiate for routing instead of Route. The class must inherit RouteBase.
controllerPrefix A prefix applied to all controllers routed to this route. This lets you “scope” controllers so they do not conflict with application controllers.

<defaults>/<add> element Attributes

These values specify the default values used when the request does not define URL parameters (see the URL attribute on the route element). See the Route.Defaults property for details on how the ASP.NET routing system uses these values.

NameDefault valueDescription
key Required – Parameter name
value Required – Default value for this parameter

<clientResources>

This section contains definitions of client resources that should be associated with the module.

<clientResources>
      <add name="string"         
           path="string"         
           resourceType="string"
           sortIndex="int"
           isMinified="bool" >
    
          <dependencies>
              <add name="string" />
              ...
          </dependencies>
      </add>
      ...
    </clientResources>

<add> element attributes

This is client resource definition.

NameDefault valueDescription
name Required – The name of the client resource. This is used as the key when loading resources. If several resources should be grouped, they can share the same name.
path Required – The virtual path to the resource on this site or a well-formed URL to an external resource. If the virtual path is relative or partial, it is automatically resolved based on the module's client resource base and relative paths.
resourceType Required – Specifies the type of the resource, must be either Script or Style.
sortIndex0Use the sort index to specify dependencies between resources with the same name.
isMinifiedfalseIndicates whether the content of this client resource is already minified.

<dependencies>/<add> element attribute

The list of names of client resources that this resource depends on.

NameDefault valueDescription
name Required – The name of the client resource that this resource depends on.

<dojo>

This section contains configuration for paths and aliases used by Dojo.

<dojo>
      <paths>
        <add name="string" path="string" />
      </paths>
      <aliases>
        <add from="string" to="string" />
      </aliases>
    </dojo>

<paths>/<add> element attributes

NameDefault valueDescription
name Required – Dojo module identifier fragment. (For example: epi/cms)
pathScripts/[Name]Path to the module root.

<aliases>/<add> element attributes

Aliases let module paths be remapped at run time.

NameDefault valueDescription
from Required – Module path under Dojo 1.7 (for example, epi/cms/contentediting/editors/SelectionEditor).
to Required – Module path under Dojo 1.8 (for example, epi-cms/contentediting/editors/SelectionEditor).

<clientModule>

This section contains client-side configuration options.

<clientModule initializer="string">
      <moduleDependencies>
        <add dependency="string"/>
        ...
      </moduleDependencies>
      <requiredResources>
        <add name="string"/>
        ...
      </requiredResources>
      ...
</clientModule>

<clientModule> element attributes

NameDefault valueDescription
initializer The (JavaScript) class has the initializer for starting the module on the client. This should inherit from the base class epi/_Module.

Example of client-side initializer class

define(["dojo/_base/declare"], function(declare) {
      return declare([], {
        initialize: function() {
            // Do any custom module initialization here
        }
      });
    });

<moduleDependencies>/<add> element attributes

Defines shell modules that this module has a dependency on the client side.

NameDefault valueDescription
dependency Name of shell module that this (client-side) module depends on.
typeRequireType of dependency. The options are:

- Require – This indicates that the named module needs to be started before this module.
- RunAfter – This module starts automatically after the named module has started.
You can combine the options.

<requiredResources>/<add> element attributes

This section defines which client resources should be loaded on the client.

NameDefault valueDescription
name The name of the client resource that is required and should be loaded. This refers to the name attribute in clientResources.

Application default module

In addition to the ordinary shell modules, there is also a module configured for the application root. This module serves two main purposes: resolving paths to the application root when no matching module is found in the module system, and enabling the application to provide functionality that would otherwise require a separate module implementation.

This default module is added to the module system as an empty module. To configure it, place a module.config file in the application root. This module.config is treated like any other module configuration with the exception that the client resource base path is defaulted to ~/ClientResources, unless configured otherwise.

Example module manifest file

<?xml version="1.0" encoding="utf-8" ?>
    <module productName="Sample Module" clientResourceRelativePath="7.3.0" loadFromBin="false">
    
      <assemblies>
        <add assembly="Sample.UI" />
      </assemblies>
    
      <route controllerPrefix="Sample">
        <defaults>
          <add key="moduleArea" value="Sample.UI" />
          <add key="controller" value="Home" />
          <add key="action" value="Index" />
        </defaults>
      </route>
    
      <clientResources>
        <add name="sample.theme" path="ClientResources/sample.css" resourceType="Style" />
        <add name="sample.widgets" path="ClientResources/widget1.js" resourceType="Script">
          <dependencies>
            <add name="sample.dependency" />
          </dependencies>
        </add>
        <add name="sample.widgets" path="ClientResources/widget2.js" resourceType="Script" sortIndex="1" />
        <add name="sample.other" path="http://domain.com/Script.js" resourceType="Script" />
      </clientResources>
    
      <dojo>
        <paths>
          <add name="sample" path="ClientResources"/>
        </paths>
      </dojo>
    
      <clientModule>
        <moduleDependencies>
          <add dependency="Shell"/>
          <add dependency="Cms" type="RunAfter"/>
          <add dependency="AnotherAddon" type="Require RunAfter"/>
        </moduleDependencies>
        <requiredResources>
          <add name="sample.theme"/>
          <add name="sample.widgets"/>
        </requiredResources>
      </clientModule>
    </module>