Entry Types Custom Slug The website I'm working on has different sections and each section different types of entries. I would like the types of entries to be shown in the URL. I have followed this tutorial to do so. 

In a site example.com where we have:


A Section called: My Section
With Entry Types: Example Entry Type, Another Entry type.


Utilizing the model from the tutorial, we could structure the URL for My Section as follows:

/my-section/{type}/{slug}

Which would give us URLs like these:


example.com/my-section/exampleEntryType/new-entry-1
example.com/my-section/exampleEntryType/new-entry-2
example.com/my-section/anotherEntryType/new-entry-3
example.com/my-section/anotherEntryType/new-entry-4


Notice that the entry types are the only part of the URL camelCased. This is  because Entry Types can only be configured to have a Name, and a Handle; and handles can NOT have dashes. This interferes with keeping URLs consistent as the rest of the site uses dashes instead of spaces

The problem I am trying to solve is: how do we get the Entry Types to stay consistent with the rest of the site?

Does anyone have any suggestion on how to deal with this? Is this a problem that should be addressed in Craft? Should I be taking another approach for this?

I had considered using categories but the way the system is setup, entry types seem more appropriate.
You could just set your "Entry URL Format" to:

my-section/{type.name}/{slug}


Your entry type names couldn't be as clean when composing entries in the CP as you'd need to set them to something like "example-entry-type", but it would work.



Now for the really clean way:

Install the Low Regex for Craft plugin.

Set "Entry URL Format" to:

my-section/{type.handle|regex('/(^|[a-z])([A-Z])/e', 'strtolower(strlen("\\1") ? "\\1-\\2" : "\\2")',(type.handle))}/{slug}


This will convert the entry type handle from camelCase to all lowercase with dashes as word delimiters. Set the entry type handles to be like "exampleEntryType" and they will become "example-entry-type" when in a slug.