Please, help me understand.
Here is my structure:
› CHANNEL_ONE
-- {title}
-- {url-title}
-- {channel-one-grid}
---- {field1}
---- {channel-two-relationship} *(multiple)*
---- {field2}
---- {field3}
› CHANNEL_TWO
-- {title}
-- {url-title}
-- {ch2field1}
-- {ch2field2}
When i’m on a CHANNEL_TWO entry page, how i can show all entries from CHANNEL_ONE that listed this CHANNEL_TWO entry as related?
Here is my current code that does not work:
<body>
{exp:channel:entries channel='CHANNEL_TWO' limit='1' require_entry='yes' disable='categories|member_data|pagination|category_fields'}
{title}
...
etc
{/exp:channel:entries}
{exp:channel:entries channel='CHANNEL_TWO' require_entry='yes' disable='categories|member_data|pagination|category_fields'}
{parents field='channel-one-grid:channel-two-relationship'}{parents:title}{/parents}
{/exp:channel:entries}
</body>
What i get:
Notice
Undefined index: channel-one-grid:channel-two-relationship
ee/legacy/libraries/relationship_parser/Tree_builder.php, line 455
Severity: E_NOTICE
Warning
Invalid argument supplied for foreach()
ee/legacy/libraries/relationship_parser/Tree_builder.php, line 455
Severity: E_WARNING
Warning
Cannot modify header information - headers already sent by (output started at ee/legacy/core/Exceptions.php:120)
ee/EllisLab/ExpressionEngine/Boot/boot.common.php, line 493
Severity: E_WARNING
Also tried this code (and its variations):
{exp:channel:entries channel='CHANNEL_TWO' disable='categories|member_data|pagination|category_fields'}
{channel-one-grid}
{channel-one-grid:channel-two-relationship:parents field='channel-one-grid:channel-two-relationship'}{parents:title}{/channel-one-grid:channel-two-relationship:parents}
{/channel-one-grid}
{/exp:channel:entries}
Getting this error:
Fatal error: Uncaught Error: Call to a member function getValues() on null in /home/s/eesystem/ee/EllisLab/ExpressionEngine/Model/Channel/ChannelEntry.php:1189 Stack trace: #0 [internal function]: EllisLab\ExpressionEngine\Model\Channel\ChannelEntry->getModChannelResultsArray() #1 /home/s/eesystem/ee/EllisLab/ExpressionEngine/Library/Data/Collection.php(86): call_user_func_array(Array, Array) #2 [internal function]: EllisLab\ExpressionEngine\Library\Data\Collection->EllisLab\ExpressionEngine\Library\Data\{closure}(Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry)) #3 /home/s/eesystem/ee/EllisLab/ExpressionEngine/Library/Data/Collection.php(245): array_map(Object(Closure), Array) #4 /home/s/eesystem/ee/EllisLab/ExpressionEngine/Library/Data/Collection.php(94): EllisLab\ExpressionEngine\Library\Data\Collection->map(Object(Closure)) #5 /home/s/eesystem/ee/legacy/models/channel_entries_model.php(25): EllisLab\ExpressionEngine\Library\Data\Collection->__call('getModChannelRe...', Array) #6 /home/s/shb in /home/s/eesystem/ee/EllisLab/ExpressionEngine/Model/Channel/ChannelEntry.php on line 1189
And even this one:
{exp:channel:entries channel='CHANNEL_ONE|CHANNEL_TWO' disable='categories|member_data|pagination|category_fields'}
{channel-one-grid}
{channel-one-grid:channel-two-relationship}
{channel-one-grid:channel-two-relationship:parents field='channel-one-grid:channel-two-relationship'}
{channel-one-grid:channel-two-relationship:parents:title}
{/channel-one-grid:channel-two-relationship:parents}
{/channel-one-grid:channel-two-relationship}
{/channel-one-grid}
{/exp:channel:entries}
I’m not surprised the field parameter doesn’t take a grid field. Does it work if you leave that out?
{exp:channel:entries channel='CHANNEL_TWO' require_entry='yes' disable='categories|member_data|pagination|category_fields'}
{parents}{parents:title}{/parents}
{/exp:channel:entries}
There’s a reported bug using Parent fields with file grids, which share a lot of code. (https://github.com/ExpressionEngine/ExpressionEngine/issues/432). If it fails, I think the best option is to add a comment there and stay subscribed.
Quick update on this one, we just pushed a fix for this to the repo and it will be in the next release.
https://github.com/ExpressionEngine/ExpressionEngine/issues/432
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.