1

I have a section that has multiple entry types. I would like to use kebab-style url segments in the URL format. I can get the articles to serve kebab URIs using this for the section's Entry URL Format:

our-firm/{type.name|kebab}/{slug}

However, this will not call the template when making the page call — needs to be:

our-firm/{type}/{slug}

So, how do you set things up to have the best of both worlds: kebab'd url segments and working templates?

1

You could have a try with dynamic routing, where you map a URL (or a url pattern) to a specific template.

Dynamic routes take priority over template paths.

If I misunderstood you, can you give an example as to what the URL is for a specific entry compared to what you need it to be?

| improve this answer | |
  • I had tried a few stabs at dynamic routing but must had an error in the regex. Now, with the regex set to our-firm/(?P<type>[^\/]+)/(?P<slug>[^\/]+) it's calling up the template. So, in the routes.php, it's 'our-firm/(?P<type>[^\/]+)/(?P<slug>[^/]+)' => 'path-to/template' which calls the right template when visiting /our-firm/kebabed-entry-type-name/url-slug. Thanks for encouraging me to revisit the approach. I'm running into an issue where the page is reporting the variable 'slug' does not exist, but as soon as I figure out the error, I'll fix the question here. – Shanan Galligan Jul 19 '17 at 16:10
  • Note, the template does set the entry with {% set entry = craft.entries.section('mySectionHandle').slug(slug).first() %} per the method outlined here: craftcms.stackexchange.com/questions/8209/… – Shanan Galligan Jul 19 '17 at 16:15

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.