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.

IF Entries expired or closed

November 02, 2012 7:55am

Subscribe [1]
  • #1 / Nov 02, 2012 7:55am

    Kaspar

    30 posts

    Hi.

    I have a Conditional Outside a Channel entries tag which should determin if a Channel has 1. Entries at all, 2. Expired entries, 3. Closed entries:
    I tried

    {if channel_short_name == "news"}

    But somehow that returns the wrapped content no matter if entries are closed or expired.
    The reason that I have the conditional is outside the channel tag is that I dont want to repeat the h2 tag.

    {if there are a displayable entries in the "news" channel, display this whole package.}
       <h2>News</h2>
    <p>   <hr ><br />
       {exp:channel:entries channel="news" limit="2"}<br />
          <div class="entry panel"><br />
            </p><h3>{title}</h3>
    <p>         {news_text}<br />
             {if news_full OR news_bild}<br />
                <div id="{entry_id}" class="toggleDiv"><br />
                   {news_full}<br />
                   {exp:ce_img:single src="{news_bild}" max_width="346" smart_scale="yes" alt="{name_orig}"}<br />
                </div><br />
                <a href="#%22class=%22show_hide" rel="#{entry_id}" class="show_hide">Mehr…</a><br />
            {/if}<br />
          </div><br />
       {/exp:channel:entries}<br />
    {/if}

    This brings me to another question:

    Is it possible to set expired entries to “closed”?

  • #2 / Nov 05, 2012 3:50pm

    Dan Decker

    7338 posts

    Hi Kaspar,

    Well, the conditional is never going to work outside of the channel entries tag pair, as the variable is not going to be set outside of the tag pair.

    Give this a try:

    {exp:channel:entries channel="news" limit="2"}
    {if count == 1}
    <h2>News</h2>
    <p>   <hr ><br />
    {/if}<br />
          <div class="entry panel"><br />
            </p><h3>{title}</h3>
    <p>         {news_text}<br />
             {if news_full OR news_bild}<br />
                <div id="{entry_id}" class="toggleDiv"><br />
                   {news_full}<br />
                   {exp:ce_img:single src="{news_bild}" max_width="346" smart_scale="yes" alt="{name_orig}"}<br />
                </div><br />
                <a href="#%22class=%22show_hide" rel="#{entry_id}" class="show_hide">Mehr…</a><br />
            {/if}<br />
          </div><br />
       {/exp:channel:entries}

    The {if count} conditional will keep your tags from repeating. Channel entries does not show expired entries by default, but you can tell it to if you need that. You can also specify a particular status if you want those entries included.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases