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.

need help listing entries from 2 channels in one single list in date order, but with specific html for each channel

September 18, 2011 7:33pm

Subscribe [2]
  • #1 / Sep 18, 2011 7:33pm

    podge

    2 posts

    Would anybody have any suggestions for me regarding the following setup.

    I have a news and events page, listing all news articles and all events from both the news channel and the events channel. Its a single list. Each channel requires its own html.

    I was thinking the following might work, but the if/else is not working in this context.

    What would be the best approach for this?

    {exp:channel:entries channel="news | events" orderby="date" sort="desc"}
    {if channel=="news"}
    SHOW NEWS HTML HERE
    {/if}
    {if channel=="events"}
    SHOW EVENTS HTML HERE
    {/if}
    {/exp:channel:entries}

    appreciate any ideas.

  • #2 / Sep 18, 2011 9:45pm

    adrake9

    57 posts

    Try using the if statement for the {exp:channel:entries} tag. don’t put the 2 if statements withing the channel entries tag. Use 2 separate channel entries.  Use the url segment to determine which one should be used.

    http://yoursite/news/

    {if segment_1 == 'news'}
        {exp:channel:entries channel = "news"}
             ...Your content here
        {/exp:channel:entries}
    {/if}
    {if segment_1 == 'events'}
        {exp:channel:entries channel = "news"}
             ...Your content here
        {/exp:channel:entries}
    {/if}
  • #3 / Sep 19, 2011 7:23am

    podge

    2 posts

    thanks for the reply. Thats not quite what i’m looking for though.

    I have the following setup:

    a url:http://mysite.com/newsandevents/


    and the html on this page which lists various news and events in one container in date order is something like this:

    <div class=“newsandevents”>
    <div class=“newsitem”>NEWS ITEM 1 HERE</div>
    <div class=“newsitem”>NEWS ITEM 2 HERE</div>
    <div class=“eventitem”>EVENT ITEM 1 HERE</div>
    <div class=“newsitem”>NEWS ITEM 3 HERE</div>
    <div class=“eventitem”>EVENT ITEM 2 HERE</div>
    </div>

    Is this possible?

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

ExpressionEngine News!

#eecms, #events, #releases