1

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.

3

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 %}
|improve this answer|||||
  • Thanks for this, Carl! Your Live Preview strategy is the missing link I hadn't considered. – Matt Stein Nov 7 '16 at 23:52
  • 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. – carlcs Nov 7 '16 at 23:58

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.