Pages

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:

  1. In the Control Panel, click your user name, and select Company Settings.

    Enabling templates for a site
  2. Click the quick menu button for the site for which you want to enable templates, and select Set modules.

    Enabling templates for a site
  3. Click Add for Templates.

  4. 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:

  1. In the Control Panel, select Modifications > Templates.
  2. Click Create template.
  3. 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.

  4. 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.

  5. 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:

  1. In the Control Panel, select Modifications > Overview.
  2. In the modifications list, find the modification in which you want to use the template, or create a new modification.

    For more information, see Managing modifications and Creating modifications.

  3. Select Content, and open the variation you want to modify.
  4. Below the content editor field, select Use template.

  5. In Template name or variable, click Select template. Either select one of the existing templates for the site, or create a new template.

    In case the default template values are included in the modification content as a JavaScript variable, you can directly enter the name of the variable in the Template name or variable field.

  6. Leave  Modification content empty. When you use a template, any content you manually enter for a modification is overridden by the template content.
  7. 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.

    {
        "welcome_message": "Welcome to my site!"
    }
    {
        "welcome_message": "Tervetuloa sivustolleni!"
    }
  8. Click Save all.
  • No labels