Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Content Wrapper XML schema reference

Content Wrapper XML schema reference

All Content Wrappers must adhere to the document structure defined in the Content Wrapper XML schema. The schema is included in the <EP_Source>/ep-assets/application-assets/src/main/assets/content-wrappers/contentWrapper.xsd directory of your Elastic Path Commerce deployment. This reference describes the elements of the schema.

content-wrapper

content-wrapper is the root element in the Content Wrapper schema.

Parent elements

None.

Attributes

None.

Child elements

Note:

Child elements are not ordered.

Name Number of occurrences Description

template-name

1

The name of the template file associated with this Content Wrapper.

wrapper-id

1

The unique, internal identifier of this Content Wrapper.

wrapper-name

1

The Content Wrapper name that appears to the user when creating Dynamic Content.

script-language

0..1

The scripting language to use in this Content Wrapper's script elements (init and resolver).

service-definitions

0..1

Contains the IDs of any service beans used in this Content Wrapper.

user-input-settings

0..1

Contains the definitions of the parameters to be configured by the marketing user when creating Dynamic Content.

init

0..1

A block of scripting code used to initialize the Content Wrapper.

template-parameters

0..1

Contains the definitions of the parameters that can be used in the Content Wrapper template.

init

Optional. A block of scripting code used to initialize the Content Wrapper.

Note:

To ensure correct parsing of non-XML scripting content, it is recommended that you enclose the contents of init and resolver elements in CDATA sections. For example:

<init>
<![CDATA[
if(x < 10) {
  // TODO
}
]] >
</init>

If you do not use CDATA sections, all special XML characters within the element such as <, >, and & must be converted to entities.

Parent elements

content-wrapper

Attributes

None.

Child elements

None.

Example

The following example shows the initialization block for the Product Content Wrapper.

<init>
	product = productService.findByGuid(productCode, loadTuner);
	store = storeConfig.getStore();
	baseUrl = productService.getElasticPath().getSfContextUrl();
	name = product.getDisplayName(locale);
	maxLength = 55;
	minLength = 35;
	if (name.length() &gt; maxLength) {
		index = name.lastIndexOf(' ', maxLength);
		if (index &lt; minLength) {
			index = maxLength;
		}
		name = name.substring(0,index) + "...";
	}
</init>

script-language

The scripting language to use in this Content Wrapper's script elements (init and resolver). Currently, only groovy is supported.

Parent elements

content-wrapper

Attributes

None.

Child elements

None.

Example

<script-language>groovy</script-language>

service-definition

Contains the ID of a service bean used in this Content Wrapper. Any service bean defined in the XML configuration files of the store can be referenced.

Parent elements

service-definitions

Attributes

Name Number of occurrences Description

name

1

The name used in this Content Wrapper to refer to the bean.

Child elements

None.

Example

The following example shows a defines a reference to the productService Spring bean. Within the Content Wrapper, scripting code can refer to this bean by using the name myProductService.

<service-definition name="myProductService">productService</service-definition>

service-definitions

Contains the IDs of any service beans used in this Content Wrapper.

Parent elements

content-wrapper

Attributes

None.

Child elements

Name Number of occurrences Description

service-definition

1..*

The ID of a service bean used in this Content Wrapper. Any service bean defined in the XML configuration files of the store can be referenced.

template-name

The name of the template file associated with this Content Wrapper. The template must be located in the same directory as the Content Wrapper.

Parent elements

content-wrapper

Attributes

None.

Child elements

None.

Example

<template-name>productContentWrapper.cwt</template-name>

template-parameter

Defines a parameter that can be referenced in the Content Wrapper template. It must contain a block of code that returns the value you want to assign to the template parameter. This value can be accessed in the Content Wrapper template by specifying the parameter name.

Note:

To ensure correct parsing of non-XML scripting content, it is recommended that you enclose the contents of init and resolver elements in CDATA sections. For example:

<template-parameter id="param1" name="Parameter 1">
<![CDATA[
if(x < 10) {
  // TODO
}
]] >
</template-parameter>

If you do not use CDATA sections, all special XML characters within the element such as <, >, and & must be converted to entities.

Parent elements

template-parameters

Attributes

Name Number of occurrences Description

id

1

The identifier used in the Content Wrapper template to refer to this parameter.

name

1

The human-readable name of this parameter. (Required, but not currently used.)

description

0..1

A description of the parameter. (Optional.)

Child elements

None.

Example

The following example shows a template-parameter that returns the filename of a product image.

<template-parameter id="image" name="image">
    return product.getImage();
</template-parameter>

template-parameters

Contains the definitions of the parameters that will be available in the Content Wrapper template.

Parent elements

content-wrapper

Attributes

None.

Child elements

Name Number of occurrences Description

template-parameter

1..*

A parameter that can be used in the Content Wrapper template.

user-input-setting

Defines a parameter that can be configured by the marketing user when creating Dynamic Content.

Parent elements

user-input-settings

Attributes

Name Number of occurrences Description

required

0..1

Set to true if the user must assign a value to the parameter or false if the parameter is optional. Default is true.

localizable

0..1

Set to true if the user can assign different values for each supported locale or false if the parameter can only have one value for all locales. Default is false.

pass-to-template

0..1

Set to true to make the parameter available in the Content Wrapper template or false if you do not want to expose it in the template. Default is true.

id

1

The parameter ID. This is the name of the variable used to refer to the setting in the Content Wrapper's code blocks.

name

1

The human-readable parameter name used to refer to the setting in the Commerce Manager client.

type

0..1

The parameter type. Supported values are:

  • StringLong
  • StringShort
  • StringShortMultiValue
  • Boolean
  • Decimal
  • Integer
  • Image
  • File
  • Date
  • Datetime
  • Url
  • Product
  • Category
  • HTML

description

0..1

This is the text that is displayed to the user when configuring the parameter.

Child elements

None.

Example

<user-input-setting localizable="false" name="productCode" type="Product"/commerce-legacy/>

user-input-settings

Contains the definitions of the parameters to be configured by the marketing user when creating Dynamic Content.

Parent elements

content-wrapper

Attributes

None.

Child elements

Name Number of occurrences Description

user-input-setting

0..*

A parameter that can be configured by the marketing user when creating Dynamic Content.

wrapper-id

The unique, internal identifier of this Content Wrapper. This value is required, but it is not displayed to the user. It must be alphanumeric.

Parent elements

content-wrapper

Attributes

None.

Child elements

None.

Example

<wrapper-id>productWrapperId</wrapper-id>

wrapper-name

The unique, human-readable name of this Content Wrapper. This value is displayed to the user when creating Dynamic Content.

Parent elements

content-wrapper

Attributes

None.

Child elements

None.

Example

<wrapper-name>Product Content Wrapper</wrapper-name>