We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Relationship parents does not work

How Do I?

shbchk's avatar
shbchk
12 posts
4 years ago
shbchk's avatar shbchk

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
       
shbchk's avatar
shbchk
12 posts
4 years ago
shbchk's avatar shbchk

PHP Version 7.3.15

MySQL 5.6.44-86.0

ExpressionEngine® CMS 5.3.2

       
shbchk's avatar
shbchk
12 posts
4 years ago
shbchk's avatar shbchk

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
       
shbchk's avatar
shbchk
12 posts
4 years ago
shbchk's avatar shbchk

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}
       
Robin Sowell's avatar
Robin Sowell
13,158 posts
4 years ago
Robin Sowell's avatar Robin Sowell

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.

       
shbchk's avatar
shbchk
12 posts
4 years ago
shbchk's avatar shbchk

Thank you, Robin Sowell!

Trying to come up with workaround, started new forum topic: https://expressionengine.com/forums/topic/252782/how-to-use-expquery-results-in-expchannel-parameter

       
shbchk's avatar
shbchk
12 posts
4 years ago
shbchk's avatar shbchk

Is there a chance EE to fix this bug? Or i need to think of alternatives?

       
Tom Jaeger's avatar
Tom Jaeger
228 posts
4 years ago
Tom Jaeger's avatar Tom Jaeger

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

👍 1
       
Edina2020's avatar
Edina2020
1 posts
4 years ago
Edina2020's avatar Edina2020

This post is so helpful!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.