Skip to main content

Front-end Config in Mosaic Templates

The front-end configuration provides a centralized location to define and manage various aspects of your user interface, including elements like the header, footer, product listings, and more.

This approach offers several benefits:

  • Consistency: Ensures a consistent look and feel across your entire storefront.
  • Flexibility: Allows for easy customization of UI elements without modifying core templates.
  • Maintainability: Keeps configuration separate from core code, making it easier to manage and update.

Guidelines / Instructions

The front-end configuration is designed to make it easier to change settings in customer themes, with settings that are not (yet) available in Foresee or the client. The configuration is neatly separated by functionality for ease of use. Below are the configuration elements explained:

Config Sections

The settings below are just a small grasp of what is available. For the full config, please look in the Mosaic Templates repository.

Account

Account-related settings.

NameDescription
can_change_personal_settingsCan a user change their personal settings?
ordertemplate_with_order_historyShow the order templates with order history
ordertemplate_with_categoriesShow the order templates categorized by group
navigation_itemsNavigational items in account navigation

Basket

Basket-related settings.

NameDescription
show_couponShow the coupon field
show_action_emptyShow the 'empty basket' button
show_action_saveShow the 'park basket' button
show_action_add_to_templateShow the 'save as order template' button
show_action_as_buttonsShow the buttons as actual .btn
show_stock_indicationShow stock indication in basket
show_uomShow UOM in basket

Checkout

Checkout-related settings.

NameDescription
show_basket_in_stepsShow basket in checkout steps
confirmation_stepIndex of the confirmation step
max_purchased_productsMaximum purchased products list
max_confirmation_list_productsMaximum purchased products list in confirmation
show_order_history_buttonShow the order history button
delivery_date_formatThe delivery date format

Footer-related settings.

NameDescription
disclaimerList of links used in the footer bottom

General

General settings.

NameDescription
show_language_flagsShow the flags of the languages in the language switch
order_form_uomShow the UOM inside the order form
recaptcha_invisibleUse the invisible reCAPTCHA?
fontawesome_typesList of the Font Awesome types that the theme uses: brands, solid, regular, light, duotone

Header-related settings.

NameDescription
topbar_uspsUse USPs in the topbar
multiple_level_menuUse the multiple level menu
multiple_level_submenuUse the multiple level submenu
multiple_level_hover_menuUse the multiple level hover menu
topbar_navigationList of links in the topbar
navigationList of links in the navigation
uspsList of USPs in the topbar

JS

Settings used in scripts.

NameDescription
datepicker_formatDatepicker format to use in the desired delivery input
localeLocale of the shop
useGoogleSessionIdUse the Google Session ID in purchase events
useLoaderModalInBasketShow a loader modal with every action related to the basket
currency_codeCode of the current currency

PDP

PDP-related settings.

NameDescription
show_reviewsShow the product rating
show_brandsShow the product brand
show_meta_product_codeShow the product code
show_sticky_order_formUse the sticky order form
ubrsList of Unique Buying Reasons

PLP

PLP-related settings.

NameDescription
show_reviewsShow the product reviews in the product tile
show_stock_indicationShow the stock indication of the product
show_my_assortmentShow the 'My Assortment' toggle in the filters
page_header_before_breadcrumbsShow the page header before the breadcrumbs
show_color_swatchesShow color swatches in the product tile

Changing the Config

The default configuration is maintained in @cloudsuite/mosaic-templates/templates/config/defaults/.

To change the config:

  1. Create a new file inside the customer theme: <customer-theme>/src/templates/config/custom.html.

  2. Create a new folder alongside it: <customer-theme>/src/templates/config/custom/.

  3. Inside the custom/ folder, create files using the same names as within the defaults. This file needs to contain a variable that can be imported in the custom.html.

    Example:

    /src/templates/config/custom/account.html
    {% set account_config = {} %}
    info

    It is not necessary to copy the complete config object, but rather only change the keys that actually need modification. This way you'll keep a nice overview of what is theme-specific.

  4. To include this config in your custom.html:

    /src/templates/config/custom.html
    {% from template('config/custom/account.html') import account_config with context %}

The 'with context' Directive

As you can see in the example above, we use the with context directive to import the account_config variable.

The with context directive is highly advised, as this ensures the right context is passed to the template.

Explanation:

'With context' is needed for imported templates/macros that need to use variables that are global and not passed directly to that template.

It sets the context of the imported template to 'local' instead of 'server'.

So a great example could be the frontend_config using a special locale setting.

If you have two users on a shop, one on /nl_NL/ and one on /en_US/, and the user on /nl_NL/ changes their language to /de_DE/, the translations in the template that are not imported with with context will share that information between all users. In this case, that means /de_DE/ AND /en_US/ will see the same translations.

Tools and Resources

Resources