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.

Trying to not repeat entries

August 01, 2011 11:13am

Subscribe [2]
  • #1 / Aug 01, 2011 11:13am

    imjared

    23 posts

    I have two channels on the same page that are essentially pulling the same blog feed. I want to give the client the ability to have an entry featured at the top so I’m using a custom status of ‘Featured’. Ideally, they should just be able to set as many entries as they want as ‘featured’ and have the newest entry stay up top while the other just gets pushed down. My template is set up in the following manner:

    {exp:channel:entries channel="blog" status="Featured" limit="1"}
        <h1>{title} lorem ipsum</h1>
    {/exp:channel:entries}
    
    {exp:channel:entries channel="blog" status="open|Featured"}
        <h1>{title} lorem ipsum</h1>
    {/exp:channel:entries}

    Obviously, EE reads these independently of each other and will repeat the entry with the status of ‘Featured’ in the second channel loop. I’m thinking I may have to alleviate this with some PHP but wanted to see if any of your smarter folks had an idea 😊

    Thanks for taking a read

  • #2 / Aug 01, 2011 11:34am

    Noah Kuhn

    60 posts

    First thing that comes to mind is place the second loop in an embed, put that embed call in the first loop and pass the url_title or entry_id from that first loop into the embed. Then exclude that url_title or entry_id from the embed loop using entry_id=“not XX”

    This does complicate things slightly and add a touch of overhead for the embed call, but I think it may be the easiest way to do this.

    Something like:

    {exp:channel:entries channel="blog" status="Featured" limit="1"}
        <h1>{title} lorem ipsum</h1>
        {embed="includes/.blogentries" exclude_id="{entry_id}"}
    {/exp:channel:entries}

    Then the embed (includes/.blogentries or whatever you want to call it) looks like

    {exp:channel:entries channel="blog" status="open|Featured" entry_id="not {embed:exclude_id}"}
        <h1>{title} lorem ipsum</h1>
    {/exp:channel:entries}

    You may have to throw a dynamic=“off” in the embedded loop, I forget.

  • #3 / Aug 01, 2011 11:37am

    imjared

    23 posts

    That makes perfect sense. Thanks Noah.

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

ExpressionEngine News!

#eecms, #events, #releases