Hey Everyone,
I’m struggling a bit trying to create a list of entries with relationships.
My client is a home developer and they would like a list of their communities that are separated by the quadrant they exist in. For example:
North West Community Name Community Name
South Community Name
West Community Name
I’m not having any issues creating list. The problem I’m having is: when there isn’t a community related to a quadrant I don’t want the Quadrant title to show and I’m finding it difficult to find a solution.
Here is a sample of my code:
{exp:channel:entries channel="quadrants" site="home"}
{if parents:no_results}
<h2>{quadrant_title}</h2>
{/if}
{parents field="quadrant"}
<a href="http://{path=communities/details/{parents:url_title}}">{parents:community_title}</a>
{/parents}
{/exp:channel:entries}Right now the conditional is showing all Quadrant titles that currently don’t have a community attached and I would like it to do the opposite.
I realize this is probably pretty simple but I’ve been banging my head against it for too long now. Any help would be greatly appreciated.
Thanks All!
Hi Mike,
Thanks for getting back to me and sorry for my not replying earlier.
Unfortunately, what I need has become a little more complicated. This is the new list structure required by the client:
North West:
-Community Name
--Development Name inside Community
--Development Name inside Community
-Community Name
--Development Name inside Community
East:
-Community Name
--Development Name inside Community
--Development Name inside Community
South:
-Community Name
--Development Name inside Community
--Development Name inside Community
-Community Name
--Development Name inside CommunitySo in addition to having Communities separated by the quadrant they exist in, I need to also display the developments that exist within each community.
So I have three channels of quadrants, communities, and developments. I have placed a relationship field in the communities channel that relates to quadrants and I have another relationship field in developments channel that relates to communities.
This is the code I currently have inside the template:
{exp:channel:entries channel="communities"}
<h2>{quadrant:title}</h2>
<ul>
<li>
<h3>{title}</h3>
<ul>
{parents field="development_assoc_community"}
<li>{parents:title}</li>
{/parents}
</ul>
</li>
</ul>
{/exp:channel:entries}Everything about this works except I get a doubling of each quadrant that has more than one community in it. Example:
North West:
-Community Name
--Development Name inside Community
--Development Name inside Community
North West:
-Community Name
--Development Name inside Community
East:
-Community Name
--Development Name inside Community
--Development Name inside Community
South:
-Community Name
--Development Name inside Community
--Development Name inside Community
South:
-Community Name
--Development Name inside CommunityI feel like I’m sooo close on this but I can’t figure out how to get rid of that doubling. Any suggestions?
This all gets confusing in a hurry.
What seems to me is that you shouldn’t be using the parents tag.
If you think about this from the top down you should be stepping down a level,then stepping down a level again. The parents tag steps back up.
In other words I think you should be using nested child tags instead.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.