Template model¶
The campaign template model defines attribute names and functions which can be used inside a template. The main elements are blocks and product positions in blocks.
The campaign template model and the product template model are similar and have the same sets of lambda expressions, and work the same way with conditional content and collections.
Campaign name¶
The name of the campaign.
Syntax¶
{{campaignName}}
Campaign description¶
The optional campaign description.
Syntax¶
{{campaignDescription}}
Examples¶
Print description if not empty
{{#campaignDescription}} <h2>{{.}}</h2>{{/campaignDescription}}
Campaign blocks¶
The blocks
collection is a top-level collection with campaign blocks. Each block has set of product positions, a type, and a template name.
Blocks¶
Syntax¶
{{#blocks}} ... {{/blocks}}
Examples¶
Iterate over all blocks
{{#blocks}}
<div class="campaign-block">
<div class="block-title">Block #{{-index}}</div>
{{#positions}}
<div class="product">
<a href="{{productLink}}">
<img src="{{productImageDesktop}}"/>
</a>
</div>
{{/positions}}
</div>
{{/blocks}}
Select second block by index
{{#blocks.idx.2}}
<div class="second_block">
...
</div>
{{/blocks.idx.2}}
Type¶
Each block has its own type which can be associated with a code block to enable customization.
Description¶
TOP_SELLERS
- Recommends products according to their strategy score. For more information, see the Top sellers panel.
CUSTOMER_BASED
- Recommends products based on the visitor's interest. For more information, see the Recommend based on customer panel.
PRODUCT_BASED
- Recommends products based on specified product sets. For more information, see the Recommend based on cart panel.
FAVORITE_BASED
- Recommends products based on the visitor's favorite products. For more information, see the Recommend based on favorites panel.
ABANDONED_BASED
- Recommends products based on the visitor's abandoned products. This panel is a mix of the Abandoned cart panel and Recommend based on cart panel. Based on the block settings, it can provide abandoned products and/or recommend products based on the abandoned products.
Examples¶
Map block title to the template type
{{#store.put.CUSTOMER_BASED}}<div class='customer_based'>Specially for you</div>{{/store.put.CUSTOMER_BASED}}
{{#blocks}}
{{#store.byName}}{{type}}{{/store.byName}}
...
{{/blocks}}
Map several values to one block type
{{#store.byName}}CUSTOMER_BASED : Specially for you{{/store.byName}}
{{#store.byName}}blockStyle.CUSTOMER_BASED : main-recommendations{{/store.byName}}
{{#store.byName}}TOP_SELLERS : Popular with our customers{{/store.byName}}
{{#store.byName}}blockStyle.TOP_SELLERS : side-recommendations{{/store.byName}}
{{#blocks}}
<div class="{{#store.byName}}blockStyle.{{type}}{{/store.byName}}">
<div class='block-title'>{{#store.byName}}{{type}}{{/store.byName}}</div>
...
</div>
{{/blocks}}
Template name¶
If the campaign block has an associated template, the name of the template can be obtained.
Description¶
{{templateName}}
- Obtain the template name.
{{#templateName}} ... {{/templateName}}
- Enter the block section if the template name is present.
Template description¶
If the campaign block has an associated template, the description of the template can be obtained.
Syntax¶
{{templateDescription}}
Block position¶
The block position in the campaign starting from 1.
Syntax¶
{{blockPosition}}
Product positions¶
A collection of product positions. This allows for getting product images and product page URLs.
Syntax¶
{{#positions}} ... {{/positions}}
Examples¶
Generate product positions with mobile images
{{#positions}}
<div class="product-position">
<a href="{{productLink}}"><img src="{{productImageMobile}}"/></a>
</div>
{{/positions}}
Table layout with a fixed number of columns
<tr>
{{#positions}}
<td class="product-position">
<a href="{{productLink}}"><img src="{{productImage}}"/></a>
</td>
{{^-last}}
{{#cmp.intMod}}{{-index}}:3{{/cmp.intMod}}
{{#cmp.testEq}}</tr><tr>{{/cmp.testEq}}
{{/-last}}
{{/positions}}
</tr>
Product position¶
The position of a product in a block starting from 1.
Syntax¶
{{position}}
Absolute product position¶
The absolute position of a product in the campaign starting from 1. {{-index}}
shows the position inside collection, but {{absolutePosition}}
shows the campaign block number.
Syntax¶
{{absolutePosition}}
Product link¶
A field with a link to the associated product page. For more information, see the Product URL template.
Syntax¶
{{productLink}}
Product image¶
Links to images made by the associated product image template.
Description¶
{{productImage}}
- The URL to the image for the selected template type, defaults to Desktop
.
{{productImageDesktop}}
- The URL to the desktop image.
{{productImageMobile}}
- The URL to the mobile image.
Mobile and desktop product images¶
There are two types of product templates: Desktop
and Mobile
. Each type can produce a different image for the same product. It can be checked if a campaign block has a template with the specific type or not. Each product position have three properties for image links: productImage
, productImageDesktop
, and productImageMobile
.
The productImage
produces a link to the selected template type. By default, it is Desktop
. A mobile template will be selected inside a mobile section or inside a withMobile
filter section.
Mobile section¶
Code inside this section will produce mobile template links by default. If the template has no mobile template, the mobile link will lead to the desktop product image.
Wrap into mobile section example
{{#mobile}} ... {{productImage}} ... {{/mobile}}
Template filters¶
Template filters allows for selecting only blocks which have or have not a specific template type. If the not most recent campaign version is to be re-sent, there is a possibility that not all blocks have a product image template. As product images cannot be produced for blocks without a template, these blocks can be excluded.
Description¶
{{#withMobile}} ... {{/withMobile}}
- Selects blocks with a mobile template.
{{#withDesktop}} ... {{/withDesktop}}
- Selects blocks with a desktop template.
Examples¶
Select only blocks without a mobile template
{{^withMobile}} {{#blocks}}...{{/blocks}} {{/withMobile}}
Select blocks with a desktop template
{{#withDesktop}} ... {{/withDesktop}}
Template checks¶
As with filters, checks can be made to find out if a template type is present. This allows merchandisers to decide what should be shown if a certain template type present or not.
Description¶
{{#hasMobile}}...{{/hasMobile}}
- Checks if the block has a mobile template.
{{#hasDesktop}}...{{/hasDesktop}}
- Checks if the block has a desktop template.