8

I have a site with 10000 events which need to expire once they have happened, the main reason for this is to keep things tidy in the CP.

We need users to view events that they have completed after they have expired.

Is there an easy way to render these entries on the front end, without creating a custom route and changing the URL??

Getting the listing is easy enough:

done: user.eventsDoing.date('<'~ now|date('Y-m-d') ).order('date desc').status('expired')

1 Answer 1

9

I don't think you can enable the default Entry Routing for expired entries. So you need to add a custom route.

To keep your current URLs, try to rebuild the default Entry Route with a custom one:

news/{slug}news/_entry

Expired entries shouldn't return 404 now any more and load your entry template. You now have to get the Entry Model manually though:

{% set entry = craft.entries.section('news').slug(slug).status('live, expired').first() %}
7
  • Exactly what i'm doing, can extend the existing template too which is useful. Thanks. Commented Feb 18, 2015 at 14:33
  • Ok, but why did you ask the question then. Seem like a solid solution, @SamHibberd?!
    – carlcs
    Commented Feb 18, 2015 at 14:34
  • It seemed like I might be missing something, but i was wrong, the route option (which i mentioned in my post) appears to be the only way to archive this. Commented Feb 18, 2015 at 14:37
  • You also need to add .status('Expired') or .status(null) to your entries query to ensure that you get Expired or Any entry respectively. Commented Feb 18, 2015 at 14:39
  • Yeah, I also just noticed it... Wouldn't do null though, because this would also show a (manually) disabled entry.
    – carlcs
    Commented Feb 18, 2015 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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