0 like 0 dislike
asked in Sections Anywhere by (133 points)
I have sections on my product pages.   I want to use the data from my product page sections on the homepage by simply specifying which product I am using.

1 Answer

0 like 0 dislike
answered by (133 points)
edited by

We've created two new files for this

atb-vars.liquid - this assigns vars_keys_array and vars_vals_array

atb-render-vars.liquid - this assigns the variable from vars_vals_array

You must pass the name of the section for this one.

Use it like this:  

{% include 'atb-vars'  data_inc: 'data_file_here', zone: 'zone_name_here', name: 'section_name_here' %}

Then to render it

{% include 'atb-render-vars' field:'field_name_here' %}

{% assign field_name = val %}

Or to render from a selected product:

{% assign inc_file = 'sa-product' | append: product.id | append: '.json' %}

{% include 'atb-vars' data_inc: inc_file, zone: 'PDP', name: 'PDP - Hero'  %}

{% include 'atb-render-vars' field:'product_title_1' %}

{% assign product_title_1   = val %}

{% include 'atb-render-vars' field:'product_title_2' %}

{% assign product_title_2   = val %}

Ask questions and receive answers from our expert developers and other members of the community.