Edited 1st July 2014 to add… With the release of EE 2.8, you can now use the new native Template Routes functionality to direct any URL to any template. The third-party offering, Resource Router, by Rob Sanchez is, however, far more powerful, and much better documented. I’d recommend it for any non-trivial routing needs. It also shines when it comes to 301-redirection strategies to deal with migrations from complex legacy systems.
The flexibility of ExpressionEngine allows you to create just about any crazy URL structure you like for your site or app. Once you get a taste of that power it’s tempting to scamper off with your new toy and plunge into schemes of pure lunacy.
Before you do, it might be an idea to make sure you’re not missing out on some of the powerful URL interpreting that you get for free, or worse, painting yourself into a proverbial corner and having to use inefficient “advanced” conditionals to get yourself out.
The ExpressionEngine documentation is replete with references to how URLs are interpreted, but let’s face it: (despite having a section dedicated to the subject) those references are sprinkled all over the place like some kind of just-out-of-reach clove-studded honey-roast ham.
Here’s my attempt at visually pulling together that information:
Sometimes it’s fun to be a lunatic.
But please: be so on purpose.
Hopefully it’ll make you pause before wasting an afternoon coding a brilliant and impenetrable set of templates that do exactly what related_categories_mode=“on” does, or make you think twice before blindly installing third party add-ons to create old fashioned static pages and then coming up with ingenious workarounds to regain bits of what you’ve lost.
If you’re new to ExpressionEngine and haven’t yet been caught out by the dynamic=“no” parameter, or have no idea what it does, the URL schematic should also help you get your head around it. At the very least it should become clear that ExpressionEngine attempts to decipher 2 things from your URL:
- A template
- A set of entries from which to pull data, filtered to your whims (categories, dates and pagination)
Combined with some of these other ExpressionEngine resources you could be halfway to EE superstar status already…
What URL approach do you usually adopt? The ‘official’ line from EllisLab—that you should be using template_group/template—makes for some pretty long urls and is not technically necessary. Take the shortcuts though, and you might regret it later.