Bug #23742 Bug Fixed

Relationship field in unparsed when using it as data for a layout variable

Version: 4.3.5 Reporter: Pedro Guimaraes

Example:

{exp:channel:entries}
{layout:set name="my_var"}
{rel_field}
{rel_field:title}
{/rel_field}
{/layout:set}
{/exp:channel:entries}

The above shows unparsed on the page. Works fine on 4.3.4.

  • Odd one- I’m not able to replicate in a simple test on the latest.

    {layout="home/layout"}
    
    Example:
    
    {exp:channel:entries channel="test"}
    <h3>{title}</h3>
    {layout:set name="my_var"}
    {rel_test}
    {rel_test:title}
    {/rel_test}
    {/layout:set}
    {/exp:channel:entries}

    Layout page is just

    <h4>LAYOUT</h4>
    
    var: {layout:my_var}
    

    I get:

    LAYOUT
    var: Sub Page One

    Do you spot anything that might differ? Do you have any grid fields with relationships in them in the same channel?

    Robin Sowell
    01st October, 2018 at 2:23pm
  • That is correct, there’s an image inside a grid field that’s accessed through the relationship.

    Pedro Guimaraes
    01st October, 2018 at 3:10pm
  • OK, try this for me. In system/ee/legacy/libraries/relationship_parser/Tree_builder.php on line 216, you’re going to comment out $all_fields = … and replace a la:

    //$all_fields = array_merge($this->relationship_field_names, array('parents', 'siblings'));
    
            $all_fields = ['parents', 'siblings'];
            foreach ($this->relationship_field_names as $field_name)
            {
                if (strpos($field_name, ':') === FALSE)
                {
                    $all_fields[] = $field_name;
                }
            }

    Does that fix it?

    Robin Sowell
    01st October, 2018 at 5:26pm
  • And per slack, it did indeed fix it!

    Robin Sowell
    02nd October, 2018 at 12:02pm
  • It solve also my problem.. Cannot really explain in detail right now but my template was rendering my code as code.. then i saw : ” {parents field=”rel_production” channel=”calendrier” orderby=”entry_date” sort=”asc” start_on=”yesterday” show_future_entries=”yes”}{/parents}” in the rendered template!.

    I was able to find the problematic code wich was an grid.. the weird thing is that ALL my {parents} tags were not working.. regardless of the channel/relationship

    benoitlemay
    02nd October, 2018 at 3:27pm
  • Yes- it was a really weird bug- we just released a patch for it today- 4.3.6.

    If you had a relationship field inside a grid field it caused weird things to happen- parent/sibling tags didn’t parse- and the issue above with the layouts.

    The bug was introduced in 4.3.5, so only existed for a few days in the wild. If you do an in-app upgrade, that will fix it and save you having to manually patch it.

    Robin Sowell
    02nd October, 2018 at 3:52pm
  • 👍🏽 Upgraded to 4.3.6 and life is good again 😂

    xtelligent
    02nd October, 2018 at 3:54pm
  • It seems that the bug is still in the new version 4.3.6, it worked correctly before the update 4.3.5

    {!– main index file –} {embed=”templates/.systems” entry_id=”{entry_id}”}

    {!– embed file located in templates/.systems –} {exp:channel:entries channel=”channel-systems” entry_id=”{embed:entry_id}” dynamic=”no”}

    {!–returns the correct result –}

    {siblings field=”available_systems”} {siblings:entry_id}

    {/siblings}

    {!– does not produce the correct result –}

    {available_systems} {available_systems:entry_id}

    {/available_systems}

    {/exp:channel:entries}

    Systems ( available_systems ) Fields List:

    System Image (channel images) ID# 46 / {system_image}

    Product Images (channel images) ID# 41 / {product_images}

    Store Options (store) ID# 61 / {inventory_store}

    System Info (textarea) ID# 47 / {system_info}

    System Optional Products (grid) ID# 59 / {system_optional}

    System Related Products (relationships) ID# 80 / {systems_related}

    System Required Products (grid) ID# 57 / {system_required}

    System Sizes (grid) ID# 48 / {system_sizes}

    Taktic Studio
    04th October, 2018 at 7:51pm
  • Hey Taktic Studio, can you send an email to support@expressionengine.com - just reference this bug and note that it’s for Robin and we’ll take a closer look.

    Robin Sowell
    05th October, 2018 at 11:28am

You must be signed in to comment on a bug report.

  • In system/ee/legacy/libraries/relationship_parser/Tree_builder.php on line 216, you’re going to comment out $all_fields = … and replace a la:

    //$all_fields = array_merge($this->relationship_field_names, array('parents', 'siblings'));
    
            $all_fields = ['parents', 'siblings'];
            foreach ($this->relationship_field_names as $field_name)
            {
                if (strpos($field_name, ':') === FALSE)
                {
                    $all_fields[] = $field_name;
                }
            }
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases