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.

Filter entries between two exp:channel:entries

July 16, 2011 8:59am

Subscribe [2]
  • #1 / Jul 16, 2011 8:59am

    Taktic Studio

    1 posts

    Hello,

    It’s my first post here and I am new to EE, but developing my forst website with it is going quite well. But now I am a little bit stuck on small issue.

    I have a “news” channel with multiple categories. On “news/index” page I want to display 4 latest news (NO MATTER THE CATEGORY) in a form of banner and after that I want to display a box for each category with latest news from that category.

    I have accomplished all of that using:

    {exp:channel:entries channel="news" limit="4" sort="desc"}
    {/exp:channel:entries}

    for the banner.

    And:

    {exp:channel:categories channel="news" style="linear"}
        {exp:channel:entries channel="news" limit="2" sort="desc" category="{category_id}"}
        {/exp:channel:entries}
    {/exp:channel:categories}

    to display news from each category.

    The only problem that I have is this. If I have a post displayed in main banner (with 4 latest news) I don’t want to display it in categories box. I can use code like:

    {exp:channel:entries channel="news" limit="2" sort="desc" category="{category_id}" entry_id="not <entry_banner_id_1>|<entry_banner_id_2>|<entry_banner_id_3>|<entry_banner_id_4>"}

    But I do not know how to save entries that I have used in the first {exp:channel:entries} and use is as entry_id parameter in second {exp:channel:entries}.

    Here is my code:

    <?php $usedEntries = array(); ?>
    {exp:channel:entries channel="news" limit="4" sort="desc"}
        <?php $usedEntries[] = "{entry_id}"; ?>
    {/exp:channel:entries}
    <?php $usedEntries = implode('|', $usedEntries); ?>
    {exp:channel:categories channel="news" style="linear"}
        {exp:channel:entries channel="news" limit="2" sort="desc" category="{category_id}" entry_id="not <?php echo $usedEntries; ?>"}
        {/exp:channel:entries}
    {/exp:channel:categories}

    But this does not work because of order in which php and ee tags are processed.

    Does anyone have any suggestions how I can solve this.

    Thanks in Advance

  • #2 / Jul 17, 2011 3:38pm

    Lisa Wess

    20502 posts

    hi, taktic -welcome to our community!

    First: this ability isn’t available out of the box.

    You might be able to use something like the String add-on, along with entry_id=“not #” to achieve this.

    I’m going to also shift this down to community help for community input on this customization.

    Thanks!

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

ExpressionEngine News!

#eecms, #events, #releases