Things I Wish I’d Known About ExpressionEngine On Day 1

Published and filed under ExpressionEngine

Filed under ExpressionEngine

Things I Wish I’d Known About ExpressionEngine On Day 1

I’ve been an avid ExpressionEngine fan since about 2007. It’s a great content management system, but here are a few things I wish I’d known right at the beginning…

1. The “advanced” conditional trap

Read this for the full detail. If you approach EE templating like ordinary web development, you’ll be shocked to find your load times increasing as you add stuff into your template that shouldn’t even be processed. So-called “advanced” conditionals are the culprit, which, in a nutshell, cause the template to fully parse all your tags in all your conditionals and then filter out the appropriate section prior to being displayed. Ouch! Edit to add: as of version 2.9.0, this problem has now been solved with a major rewrite of the conditional parser!

2. Entries, not pages

This is a huge subject, and really touches upon the fundamentals of information architecture, web governance and content strategy. Rather than post a long vitriolic rant against the ‘page paradigm’, I’ll instead direct you to read all Deane Barker’s superb posts over at Gadgetopia. Above all, try not to get sucked into creating a system in ExpressionEngine that allows your clients to manage web pages. Create a system that allows them to manage content.

3. The cost of {exp:channel:entries}

The channel:entries tag is the fundamental workhorse of ExpressionEngine. It’s awesome, but that’s why it’s also really heavy. Stop sprinkling channel entries tags all over the place - your performance will suffer noticeably and create lots of future problems. Instead, try to fetch (and cache!) your dataset(s) once and then assemble the markup later.

4. The cost of {embed}

At first glance, embedded templates seem like a great way to organise your code to make it DRY-er and more maintainable. However, these tags are even more expensive than the channel:entries tag. Every one you use instantiates ExpressionEngine’s huge and complicated template parser all over again. For simple things, try to use snippets instead, or for more complex arrangements, try…

5. Partials

Stash has become the de-facto standard for implementing a ‘partials’ methodology in your templating. You won’t look back after using this approach... however, it does help to gain an understanding of ExpressionEngine’s native ways first.

6. The url interpreting you get for free, and dynamic=“no”

Before I built my first EE site I’d already read up on what dynamic=“no” does, but I didn’t have a true understanding of what the default behaviour (dynamic=“yes”) was and the advantages of letting EE do the heavy lifting for you. Take a look at my ExpressionEngine URL Schematic to de-mystify how EE handles your URLs.

7. How to build an add-on

Ok, so maybe a little unfair to expect myself to run before I could walk, but knowing EE’s add-on architecture and database schema really helps with understanding how the whole system fits together, and also gives you more insight as to why certain things work the way they do. Along with that insight comes tolerance of what you might otherwise perceive to be absurd flaws (eg allowing a member to be in multiple member groups!).

8. Parse order

Six years down the line and I still don’t have a complete and reliable mental model of EE’s parse order. It’s almost always the reason something’s not working the way you expect it to. Take a look at Low’s Parse Order Document [PDF link] for full details.

9. The power of global variables defined in index.php

You can define your own global variables based on things like the hostname or IP address by adding them to your main index.php file. Very useful for quick and easy multi-environment setups. For serious sites, use the FocusLab Master Config instead.

10. Syntax highlighting

Saving templates as files should obviously be your default mode for any kind of serious work. To make this less painful, get Sublime Text and the ExpressionEngine bundle for beautiful (and version-controllable) template code - (though you may need to hack it a bit).

Comments

Erwin Heiser

Erwin Heiser

#2 hits the proverbial nail on the head - there’s Structure of course, but EE truly shines if you think of your site in terms of content rather than a page tree. Great article.

Sean

Sean

Great post. #1, #3 and #4 are the ones I find I have to fix up the most when looking at code by devs inexperienced with ExpressionEngine.

Simon Cox

Simon Cox

James - Really good insightful post! #8 has always been the one that silently trips me up.

Robson Sobral

Robson Sobral

#2 was one turning point of professional life.

Is really sad to see a lot of developers and designers creating and using add-ons to “do pages”.

John Moylan

John Moylan

#9 on MSM sites is an absolute lifesaver and parse order is a pig just waiting to bite you when you’re on a deadline or weekend working.

God I wish EllisLab would do something about the parse order (I wish EllisLab would do something about a lot of things) but then it’s oddities like this that lead to the remarkable Stash. Stash has changed how I work with EE, it makes my individual templates so simple to understand.

What's on your mind?