3

Ich have a concert entry which I want to expire after the concert is over.

How do I do that?

I was able to hide past entries like this:

{% set present = now|date_modify("+1 day") %}
{% for entry in craft.entries.section('concert') %}
     {% if entry.konzertdatum > present %}
       {{ entry.konzertdatum|date('d. M. Y - H:i')}} - Concert Bla
     {% endif %}
{% endfor %}

But ist it also possible to expire this entry altogether os its marked in the CP?

Or would it be better to use the post_date as a concert timestamp and then show somehow only future dates?

1

You could use my Auto Expire plugin to make those entries expire after the event is over. Just add a new expiration rule for that section with the expiration date set to:

{ konzertdatum|date_modify('+3 days 5am')|date('c') }
| improve this answer | |
  • This is great! Thank you. Thats exactly what solves this problem! – KSPR May 15 '15 at 10:27
2

You can set the Expiration Date in the control panel. It is at the bottom of the column on the right (on wide screens), or at the bottom of the page (on narrow screens). I don't think there is any way to set the Expiration Date from the konzertdatum, so you would have to either use the Expiration Date as the concert date, or maintain both of them.

| improve this answer | |
  • I just find it strange to set an expiration date for a concert. That's counterintuitive nobody does that. One should be able to set the concert date and thats it. Thats why I searched for another way. – KSPR Dec 5 '14 at 10:30
2

Not that this answers your question (Marion did a good job with that), if you stick to your current code I would change it like so:

{% set present = now|date_modify("+1 day") %}
{% for entry in craft.entries.section('concert').konzertdatum('> ' ~ present) %}
    {{ entry.konzertdatum|date('d. M. Y - H:i')}} - Concert Bla
{% endfor %}

This is how I did it for my event dates, where I didn't want the Client to use the default Expiration date field on the right. One reason for this decision was, that I have more than two dates for my Entry Type (that I theoretically could have used Expiration and Post date for). And I don't want them to be edited all over the place.

| improve this answer | |
  • What does ('> ' ~ present) do? – KSPR Dec 5 '14 at 10:31
  • @Kaspar the string '> ' gets concatenated / joined with the value of your present variable, which at this point is a DateTime object, because this is what the date_modify filter returns. But Craft is smart enough to convert the DateTime object to a string, so today you would end up with a string of '> 2014-12-06'. Used within the konzertdatum parameter, it filters your entries by this condition. – carlcs Dec 5 '14 at 11:12

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.