I have a category group with parents and each of those has one level of children. I want to display the parent and then the children, parent then children and so on. However, for the children I want to use ’ :: ’ as a separator, which means (I presume) I need to use backspace. But I want to use backspace each time I get done with a loop of children and not just at the end of a single {exp:channel:categories} loop.
Therefore, I split the code into to with the children being done with an embed. The outer loop displays the parents and the inner loop (via an embed) lists the children for that parent. Piece of cake, right? Well, not really.
=> Here’s the code to display the parents:
<ul>
{exp:channel:categories channel='my-cats' category_group='5' parent_only='yes' style='linear'}
<li class="tour-season"><a href="http://{path=/{category_url_title}}">{category_name}</a></li>
<ul>{embed='embeds/.tour_dates_list_events' parent='{category_id}'}</li></ul>
{/exp:channel:categories}
</ul>=> Here’s the code of the embed to display the children:
{exp:channel:categories channel='my-cats' category_group='5' style='linear' backspace='16'}
{if parent_id == {embed:parent}}<li class="tour-event"><a href="http://{path=/{segment_1}/{category_url_title}}">{category_name}</a> :: </li>
{/if}{/exp:channel:categories}For some reason the if statement seems to add returns or something if the conditional is not true. In other words, the backspace only works for the last set of children. For anything prior to the last set the backspace count isn’t right and for all practical purposes there is no backspaces removed - at least not as many as have been added.
Even the final children loop it’s not right. I figured need 10 spaces to remove the last ’ :: </li> ’ (9 + a return) but that doesn’t work right either.
Note: I even tried to remove all the returns in the code in embed for the children. That is, it was one single long line of code. That didn’t work either. I still picked up characters that I didn’t want (and could not see).
What am I not grasping about how EE thinks? Or is there a parsing issue in EE?
In either case, how can I do what I need to do? That is, Parent + list of children with separator; Parent + list of children with separator; and so on…