ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Only list entries that have a relationship with a specific status

May 09, 2011 12:36am

Subscribe [1]
  • #1 / May 09, 2011 12:36am

    stinhambo

    1268 posts

    I have a Notes channel and a Product channel.

    The Notes channel has a relationship field linked to the Product channel.

    I’m trying to only list Notes that are linked to Products with a specific Status and the Notes must be in date order.

    I can’t think of a way to do this without wasting cycles. Any takers?


    PS. I’m using Playa 4.

  • #2 / May 09, 2011 1:24am

    stinhambo

    1268 posts

    I managed to work out the above problem using Playa 4 (thank you Brandon!)

    First of all it was important that the log entries were in order so I had to call this first. But I could only call those that had a specific status so I decided to embed a template and pass the entry_id of the parent entry (the note) only if the child entry (the wine) had a Status of “Production”.

    <ul>
        {exp:channel:entries channel="log_entries" orderby="date" sort="desc" dynamic="no"}
        {exp:playa:children field="log_vintage" orderby="date" sort="asc" show_future_entries="yes" status="Production"}
        {embed="_functions/_log_entry_notes" title="{title}" entry_id="{parent:entry_id}"}
        {/exp:playa:children}
        {/exp:channel:entries}
    </ul>

    Then the embed takes the entry_id (so we don’t get crap loads of queries) ~

    {exp:channel:entries entry_id="{embed:entry_id}" show_future_entries="yes" dynamic="no"}
    {embed:title}
    Stuff…
    {/exp:channel:entries}

    The only negative of this code is that every note needs to be checked in order to test the Status of the child entry. If anyone can do this in SQL in a more efficient manner then I’d love to see that.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases