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.

Show expiration date only if set

January 23, 2011 4:27pm

Subscribe [3]
  • #1 / Jan 23, 2011 4:27pm

    kalkun

    4 posts

    Hello,

    have problem with expiration date conditional.

    Code:

    {entry_date format="%j"}
    {if "{entry_date format='%M, %d, %Y'}" != "{expiration_date format='%M, %d, %Y'}"}
     - {expiration_date format="%j"}
    {/if}

    Annoying part is the little ” – ” character. It shows up if no expiration date is set, expiration date itself does not.

    Results are like:
    12 -
    12 - 13
    13 -

    Can anyone say whats wrong?

  • #2 / Jan 24, 2011 8:53am

    Sue Crocker

    26054 posts

    Welcome to the ExpressionEngine forums, kalkun.

    Since you’re new to the EE forums, have you seen EEWiki:// How to Post a Support Request?

    Can you tell us which version/build of EE2.x you’re using? See EEWiki:// HowTo Determine My EE Version

    Are you displaying expired entries too?

  • #3 / Jan 24, 2011 9:02am

    kalkun

    4 posts

    Can you tell us which version/build of EE2.x you’re using?

    I’m using latest -> EE 2.1.3

    Are you displaying expired entries too?

    No, only future ones..

    {exp:channel:entries channel="events"  limit="10" show_future_entries="yes" orderby="date" sort="asc"}
  • #4 / Jan 24, 2011 3:20pm

    Ingmar

    29245 posts

    If an entry does not expire it’s expiration date will be zero. That’s still different from entry date, so your conditional shows. Try adding

    ... && expiration_date != "0" ...

    to it.

  • #5 / Jan 24, 2011 5:29pm

    kalkun

    4 posts

    If an entry does not expire it’s expiration date will be zero.

    Thanks for help, did not know that.

    Final code that works:

    {entry_date format="%j"}
    {if "{entry_date format='%M, %d, %Y'}" != "{expiration_date format='%M, %d, %Y'}" && "{expiration_date}" != "0"}
     - {expiration_date format="%j"}
    {/if}
  • #6 / Jan 25, 2011 10:36am

    Sue Crocker

    26054 posts

    Glad Ingmar was able to help. Don’t hesitate to post again as needed.

  • #7 / Jan 25, 2011 10:36am

    Sue Crocker

    26054 posts

    now really closing the thread.

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

ExpressionEngine News!

#eecms, #events, #releases