I have a listing of entries at /events that loads events/index
I also have a custom route setup to be able to list 'live' entries by week
'events/(?P<year>\d{4})/(?P<week>\d{2})' => 'events/_weekindex',
I also have a page events/past that should load past entries by loading the template events/past
That all works exactly how it should. UNTIL i set a route for events/{slug} to use the template events/_entry where i have this defined at the top of the template to allow for entries expired or live to be shown without a 404.
{% set entry = craft.entries.section('events').slug(slug).status('live', 'expired') %}
Once that route is set, going to events/past no longer loads the events/past template it now attempts to load the events/_entry template. This obviously throws errors as there is no slug defined given /past is suppose to be a listing page not a single-entry page.
Also if i do load an expired entry i get an error "Variable "slug" does not exist". Do i need to specify which segment the slug is in instead of just doing (slug) have a pre set defining slug as craft.request.getSegment(2) ?
So at the end of the day i have 2 problems here. 1 the slug is not defined based on that set. And 2 the route is causing events/past to be re-directed even though it should not be.
I should note i tried also setting a route for events/past to route to events/past template but that did not do anything. I should also note the other route i set for the year/week still works after setting the other route for events/_entry, that route is not effected at all and continues to function properly.
Posted this in the slack but I think everybody is sleeping, holding my breath people are still awake on the stackexchange. :-)
UPDATE:: I set the route for events/past BEFORE the route for events/{slug} and now the events/{slug} route does not interfere with the events/past route (that i did not even think should be necessary in the first place, nor did i know that the order mattered, is this intentional or a bug?
Update 2 I've resolved the issue by wrapping everything in a for loop instead of using set like so:
{% for entry in craft.entries.section('events').slug(slug).status('live', 'expired') %}
Doing the set as listed above did not work. So my pages are now working but i'd still like some clarification on the routing, the set, and the slug issues i was having regardless. Although everything is working it almost feels like i'm doing a work-around rather than how it's SUPPOSE to be done.
first
missing with yourset
, but I fail to see that this would mess up with your routes.