ExpressionEngine URL Schematic

Published and filed under ExpressionEngine

Filed under ExpressionEngine

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.

ExpressionEngine URL structure

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.

Why bother?

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:

The ExpressionEngine URL schematic »

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.

Beginners’ luck?

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…

War stories?

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.

Comments

AnthonyD

AnthonyD

Holy Cannoli! What a sweet, twisted and, dare I say, lunatic endeavor! NICE!

John D Wells

John D Wells

Are you serious?! Yeah man you are a loon.  But what a resource, thanks for taking the time to work this out. Brilliant.

JP

JP

Thanks for making this, can use this right now

baobaz

baobaz

wow.. it’s very good article.
I khow the diagram flow..

thanks you very much

Boyink

Boyink

Thanks for the diagram, and the links to Train-ee!

Shawn Maida

Shawn Maida

Wow!  Thanks for putting this together.

Paul

Paul

Really great and useful article. Thanks!

Meh

Meh

It just shows that EE’s handling of URLs was broken on the design phase.

I guess someone forgot to read on mod_rewrite when they coded the URL handling in EE.

URLs should in no way contain any kind of parameter such as which template to use. URLs should only reflect the hierarchy of the site itself.

James

James

@meh - In principle I agree with you. EE is treading a middle ground between providing a sensible default way of doing things and giving enough flexibility to make it into whatever you want. Combined with using the Pages module to specify precise URL=Template combinations you can pretty much go to town. If that’s not enough, you can use Doug Avery’s Freeway module which allows for fully custom routing: http://devot-ee.com/add-ons/freeway

Phil

Phil

This is genius. As someone new to EE (I have done one site and working on a second), this has cleared up a few mysteries. Well done. Nice layout.

Emmanuel

Emmanuel

Nice post. Great proposal. @meh - I totally agree with you : URLs should in no way contain any kind of parameter such as which template to use. @James - The ‘official’ line from Ellislab—that you should be using template_group/template—makes for some pretty long urls and is not technically necessary. This is exactly how I feel. Doug Avery’s Freeway module is a must have.
Very well done EE URL schematic.
Thanks for sharing, James

Robson Sobral

Robson Sobral

Hi!

I’m sorry to say this, but I guess your graphic is wrong.

The strict URL setting is about the default template group only.

If the segment_1 isn’t the default template group, the segment_2 doesn’t need to be a template. The index of this template group will be used, instead.

I took advantage of this lots of times and I just tested again to make sure.

On segment 2 section of your graphic, the sequence should be:

Is a template? -> no -> is the default template group? -> yes - > Strict URLs enabled? -> 404

This old tutorial of EE Insider took advantage of this, too: http://eeinsider.com/articles/simpler-expressionengine-urls-with-a-simple-template/

James

James

Hi Robson,

Thanks for your comment. This was brought to my attention a few weeks ago (https://twitter.com/_jamessmith/status/321953704762826752), apologies for any inconvenience, and thanks for investigating and testing. This schematic was made way back in EE1.x days over two years ago, but I’m not sure whether this mistake was there from the beginning or whether something changed.

I believe the solution here is to simply remove the ‘Strict URLs enabled?’ box in the segment 2 section - Can you confirm that this would be accurate?

Robson Sobral

Robson Sobral

Hi, James!

There’s a long time I know your URL schematic, but just now, after I saw you talking about this on stackoverflow, I notice the mistake.

My suggestion of sequence is wrong too. Please, forgive me. I wrote asleep.

Yeah, you’re right. I can just remove this box on segment_2 section.

I guess you can talk about the strict URL mode on a note, on to the legend. Something like:

“The Strict URL avoid the others templates than the index of the default template group to be accessible with and without the segment_2. Is recommended to enable it to prevent duplicated content.”

Or something like this. This post of Dan Decker is really good on explain everything about this subject: http://ellislab.com/blog/entry/expressionengine-2.6-and-strict-urls

I saw your thread on twitter. You can enable the strict URL on your sites and use the Pages Module. Personally, I use to have one template group called “pages” to all pages of Pages Module and the homepage and use this code on all files to prevent it to be accessed:

{if segment_1 == “pages”}{redirect=“404”}{/if}

Thanks, man! Bye!

James

James

Updated now to v.1.1. Looks like Strict URLs are not so limiting after all! Hopefully should be self-explanatory from the flow in the segment 1 section.

Zahari

Zahari

Hi James

Beautiful website design you have here! I would be very grateful to you if you could share with us all just what software you used to create the EE URL Schematic? It looks amazing!!!

Many thanks!

Zahari M

Jim

Jim

Just discovered this…Brilliant resource! Thank you, kind sir…

Would you consider making a PDF of it instead of an image? I’d make printing even better..

WIN88.TODAY  About Win88 * WIN88.TODAY

Hi would you mind stating which blokg platform you’re working with?
I’m looking tto start my own bblog in the near future
but I’m having a toygh time msking a decision between BlogEngine/Wordpress/B2evolution and
Drupal. The reason I ask iis becase our layout seems different then mpst blogs and I’m looking for something completely unique.
P.S Apologies for getting off-topic but I had to ask!

okrasotke.ru

okrasotke.ru

Thesе slots pгesent larger chances of winning.

season.kg

season.kg

Może być w dziwnyych godzinach, dostosujemy ѕię.

What's on your mind?