Bringing up a stale topic, you can totally achieve parent relationships within a grid field. You just need to use PHP to circumvent the Grid itself! The relationship data is 100% ok, it's just the parents tag doesn't resolve to the right place (a grid instead of an entry).
The syntax is actually quite straight-forward so I've included an example here.
What we're going to do is get the parents ourselves with PHP, and utilize the EE parse order to process an embed that will display the parents info.
For this example I've deliberately kept things simple, I've made 2 channels (parent_channel
and child_channel
), the parent_channel
has a grid on it with a label(text) and child(relationship) column on it. I've populated my entries as so:
-
Even Children (parent_channel)
- Child 2 (child_channel)
- Child 4 (child_channel)
- Child 6 (child_channel)
-
Odd Children (parent_channel)
- Child 1 (child_channel)
- Child 3 (child_channel)
- Child 5 (child_channel)
So now, as we expect from the OP we are iterating some child entries, we have a pretty standard channel entries loop here:
PHP is ON, parsed on Output
{exp:channel:entries channel="child_channel"}
<h2>{title}</h2>
<strong><em>Parents</em></strong>
<br />
<?php
$res = ee()->db->get_where('relationships', array('child_id' => '{entry_id}'));
foreach($res->result_array() as $parent){
print '{embed="templates/.parent" eid="'.$parent['parent_id'].'"}';
}
?>
<hr />
{/exp:channel:entries}
Here, please note the simple query that interrogates the relationship table. this gets out relevant parents. In this example each child only has one parent however if you note the foreach loop will take care of multiple parents. Also note how we print the embed tags with php, this way we can avoid any unforeseen 'PHP inside an embed tab, inside a channel entries tag on a template' hell, though it may not be required!
So now for that embedded template, here it really is as simple as it gets, no need for PHP but it's a standard template, as standard as it gets so you can use PHP, any EE tags, whatever you want my friends!
{exp:channel:entries dynamic="no" entry_id="{embed:eid}"}
{title}
{/exp:channel:entries}
There you have it, winner winner, chicken dinner! To make my answer 110% complete, heres the output I get (please note I'm using EE2.8.1 in my sandbox, but this all should be correct for EE 2.9.X too).
Child 6
Parents
Even Children
Child 5
Parents
Odd Children
Child 4
Parents
Even Children
Child 3
Parents
Odd Children
Child 2
Parents
Even Children
Child 1
Parents
Odd Children
Please do vote up, and/or click as the answer @Kenny (if your still active around here) if this helps y'all!
Also, Kenny, specifically notice how the embedded template is simply the parent in a channel entries loop? This means you should be able to then access your size_chart
relationship in the normal, child fashion...