1

I am trying to display one entry (most recent) on my home page from 2 different channels. So ChannelA and ChannelB.

{exp:weblog:entries weblog="weblogA|weblogB" limit="1" sort="asc" show_future_entries="yes"}
{if weblog == "weblogA"} display A {/if}
{if weblog == "weblogB"} display B {/if}
{/exp:weblog:entries}

The above worked on an EE1 site but but now on an EE2 site and channel does not work the same.

{exp:channel:entries channel="channelA|channelB" limit="1" sort="asc" show_future_entries="yes"}
{if channel == "channelA"} display A {/if}
{if channel == "channelB"} display B {/if}
{/exp:channel:entries}

Any advice?

2
  • 1
    Which is the EECMS version? I'm asking because you say "channel", but your code shows "weblog". Version 2 uses channel and version 1 uses weblog.
    – Sobral
    Oct 24, 2013 at 18:15
  • 1
    sorry if that was confusing. I used this method in an EE1 site and it worked fine, but I tried to use the same method using channels instead of weblogs and it didn't seem to work at all. I am using EE2.6 Oct 25, 2013 at 12:07

2 Answers 2

1

You are looking for channel_name

{exp:channel:entries channel="channelA|channelB" limit="1" sort="asc" show_future_entries="yes"}
  {if channel_name == "channelA"} display A {/if}
  {if channel_name == "channelB"} display B {/if}
{/exp:channel:entries}

See first comment here: http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#comments

1
  • 1
    And that first comment reads "{channel_name} ...is a shorthand of {channel_short_name}"
    – Alex Kendrick
    Oct 25, 2013 at 14:43
1

Assuming you are using EE1 you'll want to use weblog_short_name or weblog_id in your conditionals.

{if weblog_short_name == "some_weblog_name"}
    ...
{/if}

OR

{if weblog_id == "1"}
    ...
{/if}

As Robson pointed out "weblog" is specific to EE1. So if you are using EE2 just replace the word "weblog" with "channel."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.