Skip to content

Use of {parent:} causes glitch in {parent}{/parent} loop tag #5370

Open

Description

@nep

Description of the problem
With relationships, you can access parents with a loop, or you can access a single parent with direct tags.

But if you use both, you end up with unexpected data output errors (a bug).

How To Reproduce
Steps to reproduce the behavior:

  1. Create an entry with two or more parents in two different fields/channels
  2. Use one of the two examples below.
  3. See the wrong data

Screenshots / Videos / Template Code

TEMPLATE ONE - ONLY USING PARENTS LOOP:

{exp:channel:entries channel="chan-mag-articles" status="Open" limit="1" url_title="golden-goals" dynamic="no"}
{title}<br>
{parents field="mag_articles"}
{parents:url_title} -  {parents:title} - {parents:mag_cover}<br>
{/parents}
Text here<br>
{parents}
{parents:count} - {parents:url_title} -  {parents:title} - {parents:mag_cover}<br>
{/parents}
{/exp:channel:entries}

OUTPUT:
Golden Goals
fall-2024 - Fall 2024 - uploads/magazine/USC-Chan-Magazine-fall24.jpg
Text here
1 - courtney-shoda - Courtney Shoda Quote -
2 - fall-2024 - Fall 2024 - https://chan.usc.edu/uploads/magazine/USC-Chan-Magazine-fall24.jpg

NOTE: See how the second parent loop has correct data for each parent?

TEMPLATE TWO - USING PARENTS LOOP AND PARENTS SINGLE:

{exp:channel:entries channel="chan-mag-articles" status="Open" limit="1" url_title="golden-goals" dynamic="no"}
{title}<br>
{parents field="mag_articles"}
{parents:url_title} -  {parents:title} - {parents:mag_cover}<br>
{/parents}
Text here: {parents:url_title} - {parents:title}<br>
{parents}
{parents:count} - {parents:url_title} -  {parents:title} - {parents:mag_cover}<br>
{/parents}
{/exp:channel:entries}

OUTPUT:

Golden Goals
fall-2024 - Fall 2024 - https://chan.usc.edu/uploads/magazine/USC-Chan-Magazine-fall24.jpg
Text here: courtney-shoda - Courtney Shoda Quote
1 - courtney-shoda - Courtney Shoda Quote -
2 - courtney-shoda - Courtney Shoda Quote - https://chan.usc.edu/uploads/magazine/USC-Chan-Magazine-fall24.jpg

NOTE: See how the second parent loop has incorrect data for any single parent tag that was also used outside of the loop?

It seems like using the single parent tag outside of the loop increments that variable's count somehow.

Environment Details:

  • Version: 7.5.25
  • PHP Version 8.2
  • MySQL Version N/A
  • OS: N/A
  • Web Server: N/A

Possible Solution
No idea.

Additional context
The documentation should probably also be updated to reflect that single tag use is possible.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions