Chapter 1: How Does This Thing Work, Anyway?

Chapter 1: How Does This Thing Work, Anyway?

I think one of the hardest parts about learning ExpressionEngine is just grokking how it works at a conceptual level. So to help explain it let's talk about salads.

I know. Hang with me.

Let's imagine….

You're hungry for a salad.

You walk into a restaurant and sit down.

You are greeted by a waitress.

You consult the menu, and order a Garden Salad.

The waitress notes your order and walks back into the kitchen where the restaurant keeps the salad ingredients. In this particular restaurant the wait staff does the salad-making.

The waitress, however, is new. She doesn't know exactly how to make a Garden Salad.

Actually this particular restaurant has had a lot of turnover – it seemed like every week the manager had to train a new wait-person on how to make a Garden Salad.

So the restaurant manager had the idea to create a guidebook for making all the food this restaurant serves. New employees would be able to consult the guidebook rather than pestering him all the time. The guidebook has several sections in it – one section for each type of food the restaurant serves. Each specific item on the menu has a page in the guide that lists the required ingredients.

But – this manager is really picky. He wants each serving of that food item to look the same each time – so the Garden Salad you order today is identical to the one you ordered last week.

To achieve this level of consistency, the guidebook page actually has a diagram of where each ingredient in the salad needs to go on the plate. The waitress grabs the guidebook and flips to the "Salads" section. She finds the Garden Salad page, grabs a plate, and begins to assemble the salad.

She grabs some lettuce from a bowl of lettuce, then some tomatoes from another bowl, some carrots from yet another bowl, and so on with all the ingredients until the salad on her plate matches the diagram on the guidebook page. She hangs the guidebook back on the wall, and brings you your fresh Garden Salad.

You've just read a story of how EE works.

How Does This Thing Work, Anyway?

Let's look at it again.

You sit down with a computer and bring up a web browser (find the restaurant and sit at a table).

You go to Google and do a search (consult the menu).

You click a link in the results that leads to an ExpressionEngine-based website (order a Garden Salad from the waitress).

EE starts to process the request (walks into the kitchen).

EE goes to the Templates in the Control Panel (finds the guidebook).

EE first finds the correct Template Group (flips to the Salads chapter in the Guidebook), then the correct template (the Garden Salad page).

The template has specifics on what content it needs (lettuce, tomatoes, carrots, etc).

ExpressionEngine uses the instructions found in the template and goes to the Channel Library (salad bar) to gather the necessary content.

EE grabs content from Channels designed to hold one type of content (bowls in the salad bar).

EE arranges and formats the content per the HTML/CSS that is also in the template (arranges the salad per the guidebook diagram).

Once done, EE returns you the fully assembled and formatted page (finished Garden Salad) in your browser (plate).

Key Points

As with any high-level analogy it's not quite perfect, but our salad story communicates some key principles for the newbie:

  • EE provides all the heavy lifting
  • Templates provide direction on both content and presentation
  • Templates are organized into groups
  • Channels are storage containers for content
  • Channels can be bigger or smaller depending on what content they hold
  • One Channel should only contain one type of content
  • Each page in EE is usually made up of content from multiple channels
  • The primary system connection between content and templates is through the code that you as the EE developer place in a template.

Moving On

Reading the salad story you can see that one of the first things EE does when it gets a request for a web page is look for templates. Knowing that gives us a place to start - by getting some templates into our empty EE install.
We'll start slow and build up, starting with static templates. From there we'll talk about how to make templates more DRY (don't worry if you don't know what that means yet), then create Channels to hold content, and finally add the EE-specific code to templates that tells ExpressionEngine which content to go get from its Channel library. We will iterate this process a few times as we implement each section of our project site.