If I try to display nested Parent Channel categories on a Child Channel page, the category list outputs all the first-level categories at once, and then all the second-level categories. The parent/child relationship between categories is lost.
I’m not sure if this is a bug or I’m missing something critical. Using EE 2.9.
I have two related channels:
Parent - Punishments
Child - Violations
On the Violations page, I want to display the related Punishments and their categories, which are nested:
Suspension
—3 Month Suspension
—6 Month Suspension
Financial
—Fine to Governing Org
However, it is actually being output
Suspension
Financial
3 Month Suspension
6 Month Suspension
Fine to Governing Org
Stripped-down code is below.
{exp:channel:entries
channel="violations"
require_entry="yes"
disable="category_fields|member_data|pagination"}
{parents channel="punishments" field="p_violation"}
<dt>Punishment(s)</dt>
{parents:categories show_group="5"}
<dd><a href="http://{path=violations/index}">{if parent_id != 0}-- {/if}{category_name}</a></dd>
{/parents:categories}
{/parents}
{/exp:channel:entries}It’s probably worth noting that if I change the relationship around and make Violations the parent / Punishments the child, then the punishment categories nest correctly on the violations page. This is a workable solution for me for this particular site, but I have other sites I will want to upgrade to 2.9 where it won’t work—so I would appreciate knowing where I am going wrong (or if this is a bug, where I need to report it so I know to watch/wait for a fix before the other upgrades).
Thanks!