Hey folks - I’m testing this code that I’ve had in the book for demonstrating nesting advanced relationships - and it’s not working in 2.9:
<h2>The Family Tree from the Top Down </h2>
{exp:channel:entries channel="people" disable="member_data|pagination|categories"}
{if count==1} {!-- start the top-level unordered list --}
<ul>
{/if}
{parents field="offspring"}
{if parents:no_results} {!-- entries with no parents are top-level --}
<li>
{title}
{offspring} {!-- second level entries --}
{if offspring:count == 1}<ul>{/if} {!-- open the second-level unordered list --}
<li>
{offspring:title}
{offspring:offspring} {!-- third level entries --}
{if offspring:offspring:count == 1}
<ul> {!-- open 3rd level list --}
{/if}
<li>{offspring:offspring:title}</li>
{if offspring:offspring:count==offspring:offspring:total_results}
</ul> {!-- close third-level list --}
{/if}
{/offspring:offspring}
</li>
{if offspring:count==offspring:total_results}
</ul> {!-- close second-level list --}
{/if}
{/offspring}
</li>
{/if}
{/parents}
{if count==total_results}
</ul> {!-- close top-level list --}
{/if}
{/exp:channel:entries}I get
Error You have an invalid conditional in your template. Please review your conditionals for an unclosed string, invalid operators, a missing }, or a missing {/if}. Parser State: Unexpected end of Template “tree/recursive” on line 56; expected ENDIF tag for opening on line 25.
Line 25 in the template editor is:
{if offspring:count == 1}<ul>{/if} {!-- open the second-level unordered list --}We found the problem: it is in the {if parents:no_results} statement which wasn’t accounting for nested conditionals. The following patch should fix it.
In system/expressionengine/libraries/relationship_parser/Parser.php on line 278 replace:
return ($whole_tag ? $match[0] : $match[1]);with
if (stristr($match[1], LD.'if'))
{
$match[0] = ee()->functions->full_tag($match[0], $node_tagdata, LD.'if', LD.'\/'."if".RD);
}
if ($whole_tag)
{
return $match[0];
}
return substr($match[0], strlen(LD."if {$tag}:no_results".RD), -strlen(LD.'/'."if".RD));Let me know if that works on your end.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.