1

I have an entry type called people which has a superTable field called programmeAffiliations, with three fields, jobTitle, researchProgramme, primary where:

  • researchProgramme is a category field (calling a category called programmes)
  • jobTitle is just a string
  • and primary is a lightSwitch.

A person can have multiple programmeAffiliations.

I've worked out how to get people via their programmeAffiliation.researchProgramme category:

{% set filterByProgramme = craft.categories
  .group("programmes")
  .slug("some-slug")
 %}

{% set people =  craft.superTable.getRelatedElements({
      relatedTo:
        {
          targetElement: filterByProgramme,
          field: 'programmeAffiliation.researchProgramme'
        }
      ,
      section: 'people',
      criteria: {
        "section": "people",
        "orderBy": 'lastName asc',
        "with": ['portrait', 'programmeAffiliation']
      }
}) %}

But I'm struggling to work out how:

1) To get all people who where primary == 1 on their programmeAffiliation

2) To get all people who have no programmeAffiliation at all

I can of course loop over the records returned and check, but it feels a bit hacky, and that ideally I really should be able to do this somewhere in the craft.superTable.getRelatedElements call. Thoughts?

Your Answer

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

Browse other questions tagged or ask your own question.