I have a list of 'products'
they are structured like this:
They have a product that act as a parent: "product 1"
and then they have multiple variations of that parent "product 1-small", "product 1-medium", "product 1-large" etc.
but the number of their variations vary, one product may have 2 variations, the other may have 5.
I want to display them like this:
Product 1
small - large
product 2
small - xlarge
how should I do this in liquid on a jekyll static site?
you can view my website and the page I'm referring here:
https://kostasgogas.com/shop/art/prints/new-media-vector/abstract/
where the problem is apparent on the price, and size of each product.
this is an example of my data.yml:
- id: 'first-art'
type: variable
- id: 'first-art-small'
type: variation
position: 1
price: '10'
parent: 'first-art'
- id: 'first-art-medium'
type: variation
position: 2
price: '20'
parent: 'first-art'
- id: 'first-art-large'
type: variation
position: 3
price: '30'
parent: 'first-art'
- id: 'second-art'
type: variable
- id: 'second-art-small'
type: variation
position: 1
price: '10'
parent: 'second-art'
- id: 'second-art-medium'
type: variation
position: 2
price: '20'
parent: 'second-art'
- id: 'second-art-large'
type: variation
position: 3
price: '30'
parent: 'second-art'
- id: 'second-art-x-large'
type: variation
position: 4
price: '40'
parent: 'second-art'
The liquid is as follows (currently counting up to 3 variations because I don't know how to do it):
{%- assign printartworks = site.data.products-prints -%}
{%- for printart in printartworks -%}
{%- if printart.type == "variable" -%}
<h3>
{{ printart.id }}
</h3>
<div>
{%- for variation in site.data.products-prints -%}
{%- if variation.parent == printart.id -%}
{%- if variation.position == "1" -%}
€{{ variation.price }}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
—
{%- for variation in site.data.products-prints -%}
{%- if variation.parent == printart.id -%}
{%- if variation.position == "3" -%}
€{{ variation.price }}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
</div>
{%- endif -%}
{%- endfor -%}