I have a section with products. Then a section where you can create sets with the products. Means a super table field with the field quantity and a entries field.
Example:
Database Products:
Element 1,
Element 2,
Element 3
Database Sets:
Set 1 - Element 1 2x, Element 3 1x
Set 2 - Element 2 4x, Element 1 2x
really simplified but I hope it is understandable.
On the output I want a table for each element where is listed in which sets this element is included.
Example 2:
Element Page Output:
Element 1: Included in Set 1
Element 2: Included in Set 2
Element 3: Included in Set 1 and Set 2
This has worked so far with following code:
{% set elementlist = craft.superTable.getRelatedElements({
relatedTo: {
targetElement: entry,
field: 'productList.element',
},
criteria: {
section: 'sets',
}
}).all()|supersort('natcasesort', SORT_NUMERIC) %}
and then:
{% for entry in elementlist %}
<li>{{entry.title}</li>
{% endfor %}
Ok now the thing…
we have now decided to create the Sets on another section than the section which i want to put it out.
Means there is a third Section where I refer to my sets with an entries field – this should be putted out.
But when I change my variable to:
{% set elementlist = craft.superTable.getRelatedElements({
relatedTo: {
targetElement: entry,
field: ' entry.setShortcut.one().productList.element',
},
criteria: {
section: 'sets',
}
}).all()|supersort('natcasesort', SORT_NUMERIC) %}
I just get a error: Undefined offset: 0;
What can I do? Is it just to deep for a super table field or Craft CMS?
Shortly:
Before (is working): From Front End Page -> Set Page -> Super Table Field -> Check if this element is referred in min 1 row.
Now (is not working): From Front End Page -> Set Page -> Set Creator (refereed in the Entries Field of each Set Page) -> Super Table Field -> Check if this element is referred in 1 row.