Something else to consider as you have more routes is making sure that the one you want is triggered. The more specific you make the URLs, the easier that is. That’s why:
/show/{name-of-show:alpha_dash}/ep/{name-of-episode:alpha_dash}is better than
/show/{name-of-show:alpha_dash}/{name-of-episode:alpha_dash}For example, if/when you have characters as well, you’d want to avoid something like:
/show/{name-of-show:alpha_dash}/{name-of-episode:alpha_dash}
/show/{name-of-show:alpha_dash}/{name-of-character:alpha_dash}which would create ambiguous URLs. Better to have something like:
/show/{name-of-show:alpha_dash}/ep/{name-of-episode:alpha_dash}
/show/{name-of-show:alpha_dash}/ch/{name-of-character:alpha_dash}Also, it can help to avoid inadvertent mtatches if you put the more specific template routes first in the list (Developer > Templates > Template Routes):
/show/{name-of-show:alpha_dash}/ep/{name-of-episode:alpha_dash}
/show/{name-of-show:alpha_dash}/ch/{name-of-character:alpha_dash}
/show/{name-of-show:alpha_dash}Thanks Paul, that made it a lot clearer. I agree on keeping the name of the show in the url for clarity and to keep the structure the same, though I think I will go back to abbreviating the show names to shorten the urls somewhat.
One point that still confuses me a little is whether using a url like /show/{name-of-show:alpha_dash}/ep/{name-of-episode:alpha_dash} would ensure that any episode displayed actually is from the show in question…though I suppose there isn’t any real risk of a url being generated that somehow mixes it up. With characters I will need to include some kind of suffix for a few since there will be a couple of reused names.
I’ll give the new examples a try and hopefully get this together. 😊
> One point that still confuses me a little is whether using a url like /show/{name-of-show:alpha_dash}/ep/{name-of-episode:alpha_dash} would ensure that any episode displayed actually is from the show in question…though I suppose there isn’t any real risk of a url being generated that somehow mixes it up.
Right. If all of your episodes are in the same channel, because the URL titles have to be unique there wouldn’t be any chance of getting the wrong show.
FWIW, in theory your episode template could also work in the other direction. It could grab the show entry first, using the first URL segment, and then could grab the right episode entry using the show -> episode relationship field. Doing it episode first feels a bit cleaner to me, though, because each episode can only belong to one show, whereas each show will have lots of episodes.
When you have the episode section, you can snatch the show passage utilizing the relationship field. Something like: barnet tree surgeon
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.