<p>Unfortunately, you can't use Craft's built in relations service for reverse relations lookup with Super Table. This is because there's actually a special case for nested relations, such as a Matrix field. Craft's own relations service has special handling for Matrix fields, which we also need to make use of.</p>

<p>Fortunately, Josh Angell (the star that he is) has submitted a fix for this, without having to hack the core. You'll just need to alter your code to use the following:</p>

<pre><code>{% set reverseRelatedElements = craft.supertable.getRelatedElements({
  relatedTo: {
    targetElement: entry,
    field: 'specialisms.linkToPage'
  },
  section: 'barristers'
}) %}

{% for relatedEntry in reverseRelatedElements %}
  {{ relatedEntry.title }}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2016-04-13T17:56:52.537Z
@crawf, do you know if there is a way to do a similar thing if the super table in question sits within a matrix block?
Mike Vaux
CC BY-SA 3.0
2016-11-17T15:46:04.480Z
@MikeVaux did you ever work out if there is a way for ST in Matrix?
Josh Angell
CC BY-SA 3.0
2016-11-17T17:13:45.867Z
@JoshAngell No, afraid not. I didn't look into it in any great depth though.
Mike Vaux
CC BY-SA 3.0
2017-01-10T14:55:12.993Z
I'm trying to also get this working for an ST in a Matrix. Did anyone get it going?
richardpixel
CC BY-SA 3.0
2017-02-03T07:17:13.053Z
@richardpixel Any luck? I am stuck on this as well.
Danielle LeComte
CC BY-SA 3.0
2017-02-03T11:28:22.397Z
@DanielleLeComte Nope. I ended up swapping to Neo. Had similar issues but Benjamin sorted me out.
richardpixel
CC BY-SA 3.0
2015-10-27T12:34:05.840Z
2015-10-27T12:34:05.840Z
crawf
<p>I'm trying to pull through content based on items within a SuperTable entries field.</p>

<p>After searching around I currently have this:</p>

<pre><code>{% set individuals = craft.entries({section: 'barristers', relatedTo: { targetElement: entry, field: 'specialisms.linkToPage'}}) %}
{% for entry in individuals %}
  {{ entry.title }}
</code></pre>

<p>But it's not pulling anything through?</p>

<p>Any help appreciated</p>

<p>Thanks</p>

CC BY-SA 3.0
2015-10-27T12:44:03.667Z
If `entry` is the entry with the Super Table field it is the `sourceElement` of that relation not the `targetElement`.
carlcs
<relations><plugin-supertable>
SuperTable and related entries
# SuperTable and related entries

(Asked by: username_0 on 2015-10-27)

I'm trying to pull through content based on items within a SuperTable entries field.
After searching around I currently have this:
{% set individuals = craft.entries({section: 'barristers', relatedTo: { targetElement: entry, field: 'specialisms.linkToPage'}}) %}
{% for entry in individuals %}
  {{ entry.title }}

But it's not pulling anything through?
Any help appreciated
Thanks

**Tags:** relations, plugin-supertable
> **Comments:**
> **username_1**: If `entry` is the entry with the Super Table field it is the `sourceElement` of that relation not the `targetElement`.  

---

## 1 answers

### Answer by username_2 on 2015-10-27. Score: 5 | Accepted answer

Unfortunately, you can't use Craft's built in relations service for reverse relations lookup with Super Table. This is because there's actually a special case for nested relations, such as a Matrix field. Craft's own relations service has special handling for Matrix fields, which we also need to make use of.
Fortunately, Josh Angell (the star that he is) has submitted a fix for this, without having to hack the core. You'll just need to alter your code to use the following:
{% set reverseRelatedElements = craft.supertable.getRelatedElements({
  relatedTo: {
    targetElement: entry,
    field: 'specialisms.linkToPage'
  },
  section: 'barristers'
}) %}

{% for relatedEntry in reverseRelatedElements %}
  {{ relatedEntry.title }}
{% endfor %}

> **Comments:**
> **username_3**: @crawf, do you know if there is a way to do a similar thing if the super table in question sits within a matrix block?  
> **username_4**: @MikeVaux did you ever work out if there is a way for ST in Matrix?  
> **username_3**: @JoshAngell No, afraid not. I didn't look into it in any great depth though.  
> **username_5**: I'm trying to also get this working for an ST in a Matrix. Did anyone get it going?  
> **username_6**: @richardpixel Any luck? I am stuck on this as well.  
> **username_5**: @DanielleLeComte Nope. I ended up swapping to Neo. Had similar issues but Benjamin sorted me out.  

---

