Dynamic sources

Settings for sections and blocks included in a Liquid template have the option for merchants to connect one or more dynamic sources to the setting, depending on the setting type.

A dynamic source can be either:

  • A metafield value
  • A resource attribute

📘

Note

Dynamic sources aren't available for general theme settings.

Available values

Shoplazza determines the value of each available dynamic source type based on the following:

  • The resource is associated with the template that the section is in.
  • The resource settings in the context of the current setting.

For example:

Conditions Description
The section is included as part of the product template Metafields and attributes related to the product will be available for the following:
  • The section's settings
  • The settings for any block in the section
The section includes a collection type setting Metafields and attributes related to the collection will be available for the following:
  • The section's settings
  • The settings for any block in the section
The section's blocks include a product type setting Metafields and attributes for that product will be available for the block's settings.

The following table lists the available resources and their associated attributes:

Resource Attributes
product
  • title
  • vendor
collection
  • title
  • image

📘

Note

More resources and resource attributes will become available in the future.

The following outlines which setting and metafield types will be compatible:

Setting Metafield(s)
collection
  • collection_reference
color
  • color
image_picker
  • file_reference
page
  • page_reference
product
  • product_reference
richtext
  • single_line_text_field
  • multi_line_text_field
  • number_integer
  • number_decimal
  • date
  • date_time
  • weight
  • volume
  • dimension
  • rating
text
  • single_line_text_field
  • number_integer
  • number_decimal
  • date
  • date_time
  • weight
  • volume
  • dimension
  • rating
url
  • url

Default values

You can configure a setting's default value to reference a dynamic source. However, only do this if you're rendering a section or block in a context where the dynamic source value exists. For example, don't use a product-related value in a section that:

  • Can be rendered in non-product templates.
  • Doesn't explicitly have a product type setting to provide the necessary value.

Additional Liquid is invalid when using this method, so you can only reference the value directly. If you include additional Liquid, then you'll get an error.

The following is an example of a default setting that references a dynamic source:

{
  "type": "text",
  "id": "featured_product_title",
  "label": "Featured product title",
  "default": "featuring: {{ product.title }}"
}