We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Show entries that only have a parent

How Do I?

conradical's avatar
conradical
8 posts
8 years ago
conradical's avatar conradical

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 😊

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.