Studio and sitebuilderUsing sitebuilderSitebuilder liquid functions

Field Mapping

Example

{%- function field_map = "modules/module_86/front_end/functions/v1/field_mapping", field_headings: field_headings, this: this -%}

Purpose

This function is an important part of how WebApp Layouts can automatically adapt to handle different sources of data.

It takes in a headings object which stores field IDs as keys next to the names of available field slots as values. It then returns a new object using the values in this which stores the data values against those field slots so that the layout can output the data.

Adjusting the Mapping

If you add a new field to the WebApp after creating the layout with SiteBuilder, you can safely access that value via the this object as you normally would in a layout.

However, if you wish, you can also modify the existing headings in the JSON object.

Starting with this Object...

{% parse_json field_headings %}
{
"Title": "name"
}
{% endparse_json %}

You could change it so that existing {{field_map['Title']}} outputs would output values from a different field like so:

{% parse_json field_headings %}
{
"Title": "webapp_field_1_1"
}
{% endparse_json %}

Or you can add a brand new slot to the WebApp {{field_map['Extra Slot']}} and populate it with a new field's data:

{% parse_json field_headings %}
{
"Title": "name"
"Extra Slot": "webapp_field_1_2"
}
{% endparse_json %}

As the field_headings are passed into the function, the function will return an object where the required data values are stored against the correct keys.

How is this guide?

Last updated on

Powered by Holocron

Documentation