Answers.Body: <p>You need that custom route. With the dynamic URI setting the "entry route" is generated dynamically on entry save, but it stores a single, fixed route only.</p>
  
  <p>But you don't have to miss out on Live Preview when you leave the "entry route" enabled in addition to your custom route. Set up separate Live Preview URIs that you don't link to and if you prefer you can 404 the request for all non Live Preview visits.</p>
  
  <pre><code>{% if not craft.request.isLivePreview %}
      {% exit 404 %}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-07T23:52:19.887Z
Answers.Text: Thanks for this, Carl! Your Live Preview strategy is the missing link I hadn't considered.
Answers.UserDisplayName: Matt Stein
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-07T23:58:25.340Z
Answers.Text: Well, it's more a hack that a strategy. But yes, this is probably your best bet until Craft adds a way to enable Live Preview in other ways.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-07T23:42:58.150Z
Answers.LastActivityDate: 2016-11-08T00:03:44.173Z
Answers.LastEditDate: 2016-11-08T00:03:44.173Z
Answers.UserDisplayName: carlcs
Body: <p>I'm working on a project where we need to post publication <em>Editions</em>, each containing any number of <em>Stories</em>, of which there can be one of three entry types. The URL structure we're shooting for is <code>foo.com/pub/edition-slug/story-slug</code>, and I'm not sure how to set the "URL Format" field for each Section.</p>
  
  <p>For example, I've set the <em>Editions</em> Section to <code>pub/{slug}</code>, and have tried setting the <em>Stories</em> Section to the following...</p>
  
  <ul>
  <li><code>pub/*/{slug}</code>: literally includes <code>*/</code> in resulting URL</li>
  <li><code>{parent.last.uri}/{slug}</code>: only results in <code>foo.com/story-slug</code></li>
  </ul>
  
  <p>My questions, then:</p>
  
  <ol>
  <li>Is it <em>possible</em> to dynamically reference a parent Section's slug when we're not in a Structure?</li>
  <li>If no to #1, is there a more appropriate layout (rather than two independent Sections) that'd allow the Edition > Story relationship given that Editions and Stories are distinctly different? (I'm avoiding a Structure because I can't rely on editors not to make a Story top-level with nested Editions, for example—no way I understand to enforce that Edition > Story hierarchy.)</li>
  </ol>
  
  <p>I can get the URLs working with a custom route, but at the loss of a proper Live Preview and the other benefits of clean URLs like sitemap generation, etc.</p>
  
Tags: <entries><url><sections>
Title: What's the best way to build URLs for dynamic content collections?
ThreadText: # What's the best way to build URLs for dynamic content collections?
  
  (Asked by: username_0 on 2016-11-07)
  
  I'm working on a project where we need to post publication *Editions*, each containing any number of *Stories*, of which there can be one of three entry types. The URL structure we're shooting for is `foo.com/pub/edition-slug/story-slug`, and I'm not sure how to set the "URL Format" field for each Section.
  
  For example, I've set the *Editions* Section to `pub/{slug}`, and have tried setting the *Stories* Section to the following...
  
  * `pub/*/{slug}`: literally includes `*/` in resulting URL
  * `{parent.last.uri}/{slug}`: only results in `foo.com/story-slug`
  
  My questions, then:
  
  1. Is it *possible* to dynamically reference a parent Section's slug when we're not in a Structure?
  2. If no to #1, is there a more appropriate layout (rather than two independent Sections) that'd allow the Edition > Story relationship given that Editions and Stories are distinctly different? (I'm avoiding a Structure because I can't rely on editors not to make a Story top-level with nested Editions, for example—no way I understand to enforce that Edition > Story hierarchy.)
  
  I can get the URLs working with a custom route, but at the loss of a proper Live Preview and the other benefits of clean URLs like sitemap generation, etc.
  
  **Tags:** entries, url, sections
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-11-07. Score: 3 | Accepted answer
  
  You need that custom route. With the dynamic URI setting the "entry route" is generated dynamically on entry save, but it stores a single, fixed route only.
  
  But you don't have to miss out on Live Preview when you leave the "entry route" enabled in addition to your custom route. Set up separate Live Preview URIs that you don't link to and if you prefer you can 404 the request for all non Live Preview visits.
  
  ```
  {% if not craft.request.isLivePreview %}
      {% exit 404 %}
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks for this, Carl! Your Live Preview strategy is the missing link I hadn't considered.  
  > **username_1**: Well, it's more a hack that a strategy. But yes, this is probably your best bet until Craft adds a way to enable Live Preview in other ways.  
  
  ---
  
  