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.

Conditional to check if entry has expired | EE tags way

September 05, 2008 3:00pm

Subscribe [3]
  • #1 / Sep 05, 2008 3:00pm

    elemental

    77 posts

    This tip may be related to a resolved thread.

    stinhambo asked

    Is there a conditional I can use to check if the current entry has expired?

    I am using a detail template for all current and past entries. I have an “Email a Friend” link at the bottom but I only want this to show if the entry has not expired yet.

    And Sue Crocker was spot on whene saying

    I don’t have a complete answer for you, just something to start out with..

    {current_time} versus {expiration_date}

    Mark Bowen came with a PHP solution but I tried it with EE tags and it works fine too. It’s simpler to write it that way, at least for me.

    {if current_time > expiration_date}Expired data{/if}

    I am using this on a tour shedule to style the past events with a different colour. (by assigning it a class=“expired” and styling in CSS)

    {exp:weblog:entries weblog="tour_events" show_future_entries="yes" show_expired="yes" status="open|closed|cancelled"}
    {if current_time > expiration_date}
    {title}
    {if:else}
    {title}
    {/if}
    {/exp:weblog:entries}
  • #2 / Apr 15, 2009 11:00pm

    mahalie

    60 posts

    This works as expected, but it only filters after the entries are called. So if you limit to 10 and have 10 entries that are not yet expired, you will have no hits.

  • #3 / Apr 16, 2009 5:04am

    Mark Bowen

    12637 posts

    Perhaps a feature request might be in order here? 😉

    Best wishes,

    Mark

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

ExpressionEngine News!

#eecms, #events, #releases