2

I want to show previous concerts (past concerts) under a special tab. I only want to show past concerts, not current or upcoming concerts that is under a different tab. I tried the following code. Using EE 2.x

 {exp:channel:entries channel="concerts" sort="desc" limit="20" show_expired="yes" }

  {if expiration_date < current_time}

  {concert-info}

  {/if}

  {/exp:channel:entries}

This does not work it shows both upcoming concerts and past concerts. I double checked and the past concerts have an expired dates and they have expired.

3
  • 2
    Can you not just include the stop_before= tag and set that tag to now ? docs.expressionengine.com/latest/channel/… Mar 31 '17 at 7:09
  • I added to the channel:entries tag: stop_before="{current_time format='%Y-%m-%d %H:%i'} Still show upcoming shows and past show both. Only want past shows.
    – seeingis
    Mar 31 '17 at 18:26
  • Try adding parse="inward" to the end of your opening channel:entries tag Apr 1 '17 at 9:35
1

You can use condition like a below:

{if expiration_date < current_time AND expiration_date!=""}

Alternatively,you can use below query to get the records:

SELECT
    t.entry_id,
    t.title,
    t.url_title,
    d.field_id_XX AS your_custom_field
FROM
    exp_channels AS c NATURAL JOIN
    exp_channel_titles AS t NATURAL JOIN
    exp_channel_data AS d
WHERE
    c.channel_id = your_channel_id AND
    t.expiration_date != 0 AND
    t.expiration_date < UNIX_TIMESTAMP()
3
  • There has to be an easier way than this. This is way over my head.
    – seeingis
    Mar 31 '17 at 16:28
  • 2
    Please check the updated answer.
    – Jainil
    Apr 2 '17 at 3:59
  • Not working, still shows upcoming concerts and expired concerts both. I want to show only past concerts. Reminder I am using EE 2.10.1.
    – seeingis
    Apr 2 '17 at 20:08
0

Expanding on my original comment, it turns out you can use shorthand as well as long format.

{exp:channel:entries
  channel= "mychannel"
  start_on = "-12 months"
  stop_before= "yesterday"
  show_expired = "yes"
  ...
}

This will look back 12 mths until yesterday.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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