Answers.Body: <p>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?</p>
  
  <p>Update 2 I've resolved the issue by wrapping everything in a for loop instead of using set like so:</p>
  
  <pre><code>{% for entry in craft.entries.section('events').slug(slug).status('live', 'expired') %}
  </code></pre>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-11T10:37:16.573Z
Answers.Text: You could use `{% set entry = craft.entries.section('events').slug(slug).status('live', 'expired').first() %}`.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-11T10:06:17.060Z
Answers.LastActivityDate: 2015-05-11T10:06:17.060Z
Answers.UserDisplayName: Christopher Healey
Body: <p>I have a listing of entries at /events that loads events/index</p>
  
  <p>I also have a custom route setup to be able to list 'live' entries by week</p>
  
  <pre><code>'events/(?P&lt;year&gt;\d{4})/(?P&lt;week&gt;\d{2})' =&gt; 'events/_weekindex',
  </code></pre>
  
  <p>I also have a page events/past that should load past entries by loading the template events/past</p>
  
  <p>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.</p>
  
  <pre><code>{% set entry = craft.entries.section('events').slug(slug).status('live', 'expired') %}
  </code></pre>
  
  <p>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.</p>
  
  <p>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) ?</p>
  
  <p>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. </p>
  
  <p>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.</p>
  
  <p>Posted this in the slack but I think everybody is sleeping, holding my breath people are still awake on the stackexchange. :-)</p>
  
  <p><strong>UPDATE::</strong> 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?</p>
  
  <p><strong>Update 2</strong> I've resolved the issue by wrapping everything in a for loop instead of using set like so:</p>
  
  <pre><code>{% for entry in craft.entries.section('events').slug(slug).status('live', 'expired') %}
  </code></pre>
  
  <p>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.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-09T07:57:17.050Z
Comments.Text: So you're saying you got it solved? Mind adding an answer that sort order of routes matter?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-09T08:03:38.613Z
Comments.Text: There's a `first` missing with your `set`, but I fail to see that this would mess up with your routes.
Comments.UserDisplayName: carlcs
Tags: <entries><routes><routing><expired>
Title: Routes + Expired + Slugs
ThreadText: # Routes + Expired + Slugs
  
  (Asked by: username_0 on 2015-05-09)
  
  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.
  
  **Tags:** entries, routes, routing, expired
  
  > **Comments:**
  > **username_1**: So you're saying you got it solved? Mind adding an answer that sort order of routes matter?  
  > **username_1**: There's a `first` missing with your `set`, but I fail to see that this would mess up with your routes.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-05-11. Score: 1 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_1**: You could use `{% set entry = craft.entries.section('events').slug(slug).status('live', 'expired').first() %}`.  
  
  ---
  
  