I have two channels: 1. Brands 2. Batteries
I create batteries (like AA, AAA etc..) and relate them to a brand: Battery = AAA —> Brand = Panasonic.
I need to list out all Parents that have children. Brand is Child and Battery is Parent: Brand 1 1. Battery 2. Battery
Brand 2 1. Battery 2. Battery
Brand 3 No Batteries
I have a page template that does this but also lists Brands that don’t have parents. How do I show Brands that only have parents?
Here is my template code:
<div class="row">
<div class="col-sm-12">
{exp:channel:entries channel="brands" dynamic="no" orderby="title" sort="asc"}
<div class="row clearfix m-b-50">
<h2>{title}</h2>
{parents field="brand" channel="batteries" orderby="title" sort="asc" limit="6" category="{segment_2_category_id}"}
<div class="col-md-2">
<a href="/{segment_1}/{segment_2}/{parents:url_title}/">_ <div class="image m-b-10">_ {parents:image}_ </div>_ {parents:title}_ </a>
</div>
{/parents}
</div>
{/exp:channel:entries}
</div>
</div>
Let me know if that was clear. Relationships can get confusing 😊
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.