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.

two channels with different source code

September 20, 2011 1:35pm

Subscribe [3]
  • #1 / Sep 20, 2011 1:35pm

    Marcuse

    166 posts

    I want to display the latest entry on the front page but sometime it’s a movie and sometime a text in differt channels how can I redirect to necessary code

    What kind of if code I must use or must I check of a field in a entry is used

    {if} ... last entry is in bloghouse display:
    
    {exp:channel:entries channel="bloghouse" disable="member_data|pagination" sort="desc" limit="1"}
    
        display bloghouse - this bloghouse source
    
    {/exp:channel:entries}
    
    {else if} ... last entry is in moviehouse display:
    
    {exp:channel:entries channel="moviehouse" disable="member_data|pagination" sort="desc" limit="1"}
    
        display moviehouse - this moviehouse source
    
    {/exp:channel:entries}

    Greetings

  • #2 / Sep 20, 2011 11:35pm

    Dan Decker

    7338 posts

    Marcuse,

    Let’s see if we can sort this out. You can pipe multiple channels into {exp:channel:entries} and orderby date. For example:

    {exp:channel:entries channel="bloghouse| moviehouse" orderby="date" disable="member_data|pagination" sort="desc" limit="1"}
    template code here
    {/exp:channel:entries}

    Ordering by date and limiting to 1 will pull the most recent entry from the correct channel. Is there anything else we can assist you with?

    Cheers,

  • #3 / Sep 21, 2011 12:28pm

    Marcuse

    166 posts

    This is not what I mean.

    Again a better explanation I hope:

    I want to display the latest entry I have to channels (bloghouse|moviehouse)

    But the code for displaying a movie is different than the code from bloghouse so EE must display the right channel where the latest entry is posted so it can display the right template code

  • #4 / Sep 21, 2011 3:15pm

    Sue Crocker

    26054 posts

    Hi, Marcuse.

    If you just use the short field names for each channel in the form, EE will only display the ones where there is data.

    So it will cover both channels.

    Example:

    {exp:channel:entries channel="bloghouse|moviehouse"}
    <h3>{title}</h3>
    <p>{bloghouse_data}<br />
    {moviehouse_data}<br />
    {/exp:channel:entries}

    Does that help?

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

ExpressionEngine News!

#eecms, #events, #releases