2

I'm been kicking myself for hours and going round in circles trying to get list of entries displayed by category when the category is selected from within a SuperTable (static table) row. I would really appreciate if someone could please help point me in the right direction.

I have a structure entries section named "services" with a number of entries created. I have a category group named "serviceCategories" I have a "SuperTable" static table field handle named "service" In my SuperTable I have a row named "serviceCategory" which allows me to select a single category from the category group named "serviceCategories".

I'd like to create a standalone web page that displays all the category titles with the list of related entries.

I've tried:

{% set categories = craft.categories.group('serviceCategories') %}
{% for category in categories %}

  {{ category.title }}

  {% set services = craft.entries.section('services').relatedTo(
    { targetElement: row.serviceCategory }
  ) %}

  {% for service in services %}
    {{ service.title }}
  {% endfor %}

{% endfor %}
3

Not sure if you're still looking for an answer, but relation support has just been added to Super Table 0.3.7. Previously, relations wouldn't work with Super Table, as its a little bit of a special field, having sub-queries to perform for relations (each row).

You can now query fields just like Matrix:

{% set reverseRelatedElements = craft.supertable.getRelatedElements({
 relatedTo : {
   targetElement: entry,
   field: 'superTableFieldHandle.columnHandle'
 },
 elementType : 'Entry',
 criteria: {
   section: 'someSection'
 }
}) %}
1

Do you need the targetElement option? Could you not just do:

{% set services = craft.entries.section('services').relatedTo(row.serviceCategory) %}

Also where is row coming from, because your not defining that anywhere?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.