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
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.
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.
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.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.