Description
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:
- Create an entry with two or more parents in two different fields/channels
- Use one of the two examples below.
- 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