Modification templates allow you to define the UI code for a modification once and then automatically reuse that code across multiple modifications. Frosmo supports mustache.js templates.
There are many benefits to using templates:
- You can use the same template in multiple modifications.
- You can separate data (for example, product data) from modification content structure.
- You can modify the data before displaying the modification.
Enabling and disabling templates for a site
Before you can use templates on a site, you need to enable the templates module for the site.
Only certain Frosmo users can enable and disable site modules. If you're a company user, your Frosmo team enables and disables the modules for your sites.
To enable templates for a site:
In the Control Panel, click your user name, and select Company Settings.
Click the quick menu button for the site for which you want to enable templates, and select Set modules.
Click Add for Templates.
- Click Close.
To disable a template, in the Set modules view, click Active for Templates, and click Close.
Creating a template
To create a template:
- In the Control Panel, select Modifications > Templates.
- Click Create template.
Enter a name for the template.
Exporting the template is enabled by default. Exporting the template adds the template content to the custom script of the site, which is mandatory for most modifications to function as expected. Exporting also allows you to access the template content through the browser console for debugging purposes.
Enter the template content. The content in the following figure is an example of a modification content structure for a welcome message that you can, for example, modify based on the visitor's locale or language selection.
- Click Save.
Using a template
The following example shows how to use a template to display a different welcome message to visitors based on their language selection on the site. As a prerequisite, you must create segments for visitors based on their language selection and define those segments for the modification in the modification display options.
To use a template in a modification:
- In the Control Panel, select Modifications > Overview.
In the modifications list, find the modification in which you want to use the template, or create a new modification.
- Select Content, and open the variation you want to modify.
Below the content editor field, select Use template.
In Template name or variable, click Select template. Either select one of the existing templates for the site, or create a new template.
- Leave Modification content empty. When you use a template, any content you manually enter for a modification is overridden by the template content.
In Template defaults, enter the data or content you want to use in the template. For example, you can create one modification for each language version for your site, and populate the template default for each modification with language-appropriate content. The following examples show an English and a Finnish version of the welcome message.
- Click Save all.