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 only entries with no relationship

How Do I?

DustinS's avatar
DustinS
11 posts
10 years ago
DustinS's avatar DustinS

I’m building a website for a church. I have a whole list of sermons. Most sermons are part of a sermon series. I have 2 channels: Sermons & Sermon Series. The My Sermons channel has a relationship field that allows you to say which Sermon Series it is a part of. I have this all working properly, using

parents

.

Where I am running into a problem is when a Sermon is not part of a Sermon Series. I want to show a list of all Sermons that do not belong to a Sermon Series. I’ve attempted this a few ways:

1:

{if sermon_series:count == "0"}show sermons{/if}

2:

{if sermon_series:title == ""}{/if}

I’ve tried a few other things as well. Thus far, nothing has worked.

Any ideas? Something I am missing?

Thanks

Dustin

       
Ingmar's avatar
Ingmar
29,245 posts
10 years ago
Ingmar's avatar Ingmar

Try something like this:

{exp:channel:entries channel="my_sermons"}

  {parents}
    This sermon belongs to the {parents:title} series.

    {if parents:no_results}
    This sermon doesn't belong to a series.
    {/if}
  {/parents}
{/exp:channel:entries}

There is excellent documentation on relationships, by the way. That said, I can’t but help and wonder if in your case simply using categories might not be an easier approach.

       
DustinS's avatar
DustinS
11 posts
10 years ago
DustinS's avatar DustinS

Thanks for the reply. This is one of the things I tried before. when I use

{if parents:no_results}

I get the full list of sermons, ones that are and are not in a series.

I currently have this setup using categories, and it works, but using the relationship field seemed like the perfect idea for making it a seamless process for church admins to add new series/add sermons to the series.

       
Derek Jones's avatar
Derek Jones
7,561 posts
10 years ago
Derek Jones's avatar Derek Jones

The Channel Entries tag will return all of the results for the channel. You could use the conditional Ingmar recommends to conditionally display what you are looking for. But if you want the results themselves to be filtered by having/not having a relationship, you will need to look at an add-on like Solspace Super Search or Low Search.

       

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.