contact

Expression Engine tips, part one

Enjoy this article? Share it with others.

Bookmark on del.icio.us Bookmark on Design Float Bookmark on Digg Bookmark on Google Bookmark on Slashdot Bookmark on StumbleUpon Bookmark on TwitThis

Using Expression Engine to manage events.

We're using Expression Engine to build a site for an upscale restaurant in Illinois. Client needs are pretty straightforward, but there are a few elements of the site that took a little trial and error. We'll discuss one of them here to illustrate a best practice for managing data in Expression Engine.

There is a main blog, we've left its title alone, “Default site weblog”, which contains all the top-level pages of the site.

On one of the pages, we need to display a list of upcoming musical performances at the restaurant. The easiest thing to do is have the client enter this data manually on a page. However, this can be prone to errors, requires duplication, that is, reentering the same info for an artist for each time they perform, and it also requires the client to remove past events manually.

Instead, we've created two blogs: performers, which contains the fields:

  • Performer name
  • Performer style description, i.e., “Jazz Combo”
  • Performer site URL (optional)

and events, which contains the fields:

  • Event title (a required Expression Engine field)
  • Performer name (cross-referenced via the related field feature)
  • Date/time
  • Time range (this is in addition to date/time to allow the client to specify, for example, 8:00 - 10:00 p.m.)
  • Event description

Finally, we have a simple Expression Engine template called “event-list” that loops through all events from the current date or after, and also pulls the relevant performer information.

In the “Default site weblog”, we have a custom drop-down field called “include-below”, with a list values corresponding to templates like “event-list”. In the corresponding template for this blog, we use a conditional embed statement, like this:

This allows the client to enter info in to the body field of the weblog, while keeping the code that lists events (or does other dynamic things) hidden from the client. It also means that we can add new display functionality to the site by simply creating a new template and adding it to the custom field drop-down options.