November Happy Hour will be moved to Thursday December 5th.

Loading...
Area: Optimizely CMS
Applies to versions: 12 and higher
Other versions:
ARCHIVED This content is retired and no longer maintained. See the version selector for other versions of this topic.

Configuring module.config

Recommended reading 
Note: This documentation is for the preview version of the upcoming release of CMS 12/Commerce 14/Search & Navigation 14. Features included here might not be complete, and might be changed before becoming available in the public release. This documentation is provided for evaluation purposes only.

The following XML pseudocode 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 Configuration topic describes the syntax used in the description 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

Name Default value Description
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 for paths to client resources specifically. 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.
loadFromBin true Whether to load all assemblies from the bin folder of the module. Otherwise, only assemblies listed under the assemblies element are loaded.
routeBasePath Optional base path for routes to the module. 
viewFolder Optional name of folder containing views for the module. If not given, the expectation is that the views are in a folder named as <moduleName>.Views.
authorizationPolicy "DefaultShellModulePolicy" Specifies which policy that should be applied to the module. If not specified then a default policy that require any of roles WebEditors, WebAdmins, CmsAdmins, or Administrators.
moduleJsonSerializerType JsonSerializerType.Resolve Specifies which JSON serializer the module should use. JsonSerializerType enum has the following values:
  • Resolve. If the shell module contains any Newtonsoft JSON converter that is 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. 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.
prefferedUiJsonSerializerType JsonSerializerType.Resolve Specifies 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 that is 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. 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

Name Default value Description
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

Name Default value Description
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 ({}).
clientSideOnly false Determines 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 makes it possible to “scope” controllers so they do not conflict with application controllers.

<defaults>/<add> Element Attributes

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

Name Default value Description
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.

Name Default value Description
name   Required. The name of the client resource. This is used as the key when loading resources. Several resources can share the same name if they should be grouped.
path   Required. The virtual path to the resource on this site or well-formed URL to external resource. If the virtual path is relative or partial, it is automatically resolved based on client resource base and relative paths of the module.
resourceType   Required. Specifies the type of the resource, must be either Script or Style.
sortIndex 0 Use the sort index to specify dependencies between resources with the same name.
isMinified false Indicates whether the content of this client resource is already minified.

<dependencies>/<add> Element Attributes

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

Name Default value Description
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

Name Default value Description
name   Required. Dojo module identifier fragment. (For example: epi/cms)
path Scripts/[Name] Path to the module root.

<aliases>/<add> Element Attributes

Aliases allow module paths to be remapped at run time.

Name Default value Description
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

Name Default value Description
initializer   The (JavaScript) class which 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 on the client side.

Name Default value Description
dependency   Name of shell module that this (client-side) module depends on.
type Require Type 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.
It is also possible to combine the above options.

<requiredResources>/<add> Element Attributes

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

Name Default value Description
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 always 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>
Do you find this information helpful? Please log in to provide feedback.

Last updated: Jul 02, 2021

Recommended reading