Building an ExpressionEngine Site - Chapter 14

In which we implement the Services section.

In this chapter of the Building an ExpressionEngine site series I’ll work you through implementing the Services section of our example site.  Between using EE objects that are already created (field groups, category groups, etc) and copying/tweaking existing templates I can get you through it in one chapter.

Wa-a-ay back in chapter 3 we looked at the possibility of the Services section sharing a category group with the Products section. 

I think this is a good idea - as many businesses will offer a set of products and services that are related to each other.  Being able to show those relationships on the website would then be valuable - to ensure that clients/users can be fully served, and (from a business perspective) to not miss out on potential upsell opportunities.

Now I’ve gone and used the word “relationships” so I should take a moment and explain the approach here.  ExpressionEngine has a few different ways of - generically speaking - relating content.  One way is weblogs - if two posts are in the same weblog they are inherently related.  Another way is categories. Having two posts assigned to the same category establishes another content relationship between those two posts.  You can think of two posts in the same category as being more closely related than two posts in the same weblog but not in the same category.

New lets push it another way - category groups can also be assigned to more than one weblog.  So - if two posts are in different weblogs but assigned to the same category there is a relationship there that we can use to display those two posts on the same page.  This is the approach I’ll be assuming.

EE also allows more formal content relationships.  These formal relationships are also valuable, but are (IMHO) more advanced. I think it’s best to get a grip on the ins and outs of categories before looking at formal relationships.

Having said all that - this chapter will focus on getting the Services section implemented.  In the next chapter we’ll look at tying the Products and Services together from a presentational viewpoint.

OK - so here’s the overview list of what needs to happen for the Services section:

  • New Services weblog, using existing field group and category group
  • Content entry
  • Template copying/tweaking
  • New Section Intro post in Miscellaneous Content weblog
  • Update main navigation

New Services Weblog
You’ve created a couple weblogs now, so I’m not going to walk through the specific steps (you can review earlier chapters if need be).  Just create your new weblog, and name it.  I’m naming mine with a full name of “Building Series Services” and a short name of “bees_services”. 

Once your weblog exists, use the “edit groups” link to assign it a field group of “simple_content” and a category group of “bees_products”.

Content Entry
Your new weblog is empty - so best to get some content in there before moving on.  Even if it’s “greeking” without some content you won’t really know if your templates are working or not.

Enter about a half-dozen posts, and remember to assign each one to a category. Two per category should work well.

Template Copying & Tweaking
Functionally the Services section of the site will be the same as the Products section; the index template will be a list of Services categories, clicking a category will return a list of the entries in that category, and clicking an entry will bring up the detail for that entry.

So let’s jump-start our template development by copying the 3 Products related templates: the index template, the product list template, and the product_detail template.  I’ve named mine in the following manner:

  • chapter_14_services
  • chapter_14_services_list
  • chapter_14_services_detail

Now for the tweaking.

To the Index template I had to change the following:

  • Page title
  • my_location main navigation location flag
  • my_url_title variable in the search section intros embed
  • Weblog names
  • Link targets
  • Text in the “View Products” text link

Small Change of Direction - another Custom Category Field
I also removed the category photos and line manager information.  After reviewing the results, I’ve decided that the category description I wrote for the Products just doesn’t cut it for describing the Services.  I could re-write the description, but rather than making one description more generic I’d rather use another custom category field for describing the Services.  You may choose to do it differently.

I’ve added a custom field to the bees_products category group, called “services_description” (text area, no formatting).  I’ve gone back and added a services-specific description to each of my existing categories.  I’ve also changed out the field in the Services index template, trading “category_description” for the new “services_description”.

Back to Tweaking
To the chapter_14_services_list template I made the following changes:

  • Page title
  • Weblog name
  • my_location variable
  • the_url_title variable
  • Weblog names in main weblog:category heading tag and weblog:entry tag
  • Link targets
  • Linked text
  • Replaced category_description with services_description
  • Got rid of the images, and just made linked titles

Note that you could, if you desired more content on this page, use a new custom field set for the Services weblog, and create a “summary” field to use here.  Or, similar to what we did with the Latest Products section, use the word_limit plug-in to pull the first 50 characters of text from the page_body field.  At this point I’m going to keep this page simple with linked titles to each Service description.

To the chapter_14_services_detail I made the following changes:

  • Page title
  • Weblog names
  • my_location variable
  • my_url_title variable
  • weblog name in the weblog:entries tag
  • changed fieldset in the weblog:entries tag

Download the new templates
Here are the three templates required for the Services section:

New Post in Miscellaneous Content Weblog
OK - with those three templates in place the code is now looking for a Section Intro to pull with a url_title of “services”.  Since that doesn’t exist, we need to publish that into the Miscellaneous Content weblog.

Once that’s published and saved, if you refresh any of your Services templates they should load the new intro.

Updating Main Navigation
Our main nav still isn’t highlighting the Services section as active - and it’s not hooked up to the new templates.  Let’s fix that. In your main_nav embedded template you’ll need to to update the li for the Services section from:

<li><a href="#" ><span>Services</span></a></li>

to:

<li><a{if '{embed:my_location}'=="services"} class="selected"{/if} href="/splaat/building_series/chapter_14_services/"><span>Services</span></a></li>

You can download the entire updated template here: chapter_14_main_nav.txt

With that change saved you should be able to refresh your site and get the main nav to light up, and be connected.

Here is the link to my copy of the updated project site: Chapter 14 Services.

Next up—we’ll modify the Products section to show related services for each product category.

Back to Chapter 13
On to Chapter 15

Learn ExpressionEngine® Fast

Visit Train-ee.com for the latest in ExpressionEngine training designed with one goal in mind - to get you up to speed on ExpressionEngine® as quickly as possible.

The latest Train-ee Products:

The latest from the Train-ee blog:

Comments

1

November 29, 2007

Still hanging in there… I’ve just got to subscribe to each chapter’s comments thread - or risk the chance of missing all the valuable feedback. Great insights on organizing the website in this chapter!
Also this “get a grip on the ins and outs of categories before looking at formal relationships.” Basics, Basics, Basics.

Thanks again Michael, for keeping all of us would be EE developers grounded here.

2
(Author)
November 29, 2007

Hey Ty -

Thanks as always for the comments.  I wonder with each additional chapter how many folks are keeping up..wink

Just FYI - there is no chapter-specific comments RSS feed.  I only have an RSS feed for any/all comments from the weblog.

3

November 29, 2007

Great MIchael, just signed up for that one from the available feeds drop down (bottom right). What in the world is SSdutch, lol?

4
(Author)
November 29, 2007

What, you haven’t explored all of Boyink.com?  wink

SSDutch is the name of my 1964 Jeep CJ6 project.  I had a ‘66 CJ5 named “Dutch”, but it was too small.  A CJ6 is the same as a CJ5 just 20” longer - so I named it “SupersizeDutch” then shortened it to SSDutch.

It even has a vanity doman:  http://www.ssdutch.com

5

November 29, 2007

OMG, a vanity domain, that’s a new terminology on me, too much!
So are you forwarding the domain then? That’s really a whole ‘nother site over there sort of. Are you running the multiple domain manager here on your site, prolly not?
Now you have me wondering just how in the heck this place is put together? *scratches head… says hmmm*

6
(Author)
November 29, 2007

Nah - just a forward to http://www.boyink.com/splaat/ssdutch/ (Hobbies > SSDutch).

7

November 29, 2007

I am developing a site for a church and decided on using EE as the CMS. Since I had never used EE before I was in search of information (beyond the docs) on how to implement EE. I found this series from a post on the EE site and I wanted to thank you for taking the time to write this information. It has helped me get passed the EE learning curve. Your use of a store for you example is good as it translates well and I have been able to easily adapt the information to my needs. I look froward to the rest of the series (particularly the blog and implementing search).

Thanks,
Adam

8
(Author)
November 30, 2007

Hi Adam - thanks for the comments.

Actually, the default templates EE installs with are blog and search related - so if I’m going too slow on my series at least you have those templates to pick apart.

9

December 01, 2007

Mike the series has been unbelievably helpful.
Thanks a lot.

10

December 06, 2007

Mike,

I finally made it to (and through) Chapter 14. Thanks, yet again, for another easy-to-follow and beneficial EE tutorial!

Much obliged!

p.s. - What’s up with Jambor-EE copying your build an EE site idea? smile For those of us huffing and puffing up the learning curve, it will be interesting to see another take on how to built out a site.

11
(Author)
December 06, 2007

Hey - the more the merrier...I hope to learn some stuff from them as well!

I do like that they are building more of a community-driven site.  I haven’t done many of those so seeing how they’d go about it is valuable for me too.

12
(Author)
January 15, 2008

FYI:  The Building an ExpressionEngine Site series is now available for purchase as an eBook on the newly-launched Train-ee.com.

13

May 13, 2008

mike you are such a star smile

thanks so much for the time and effort you’ve put into this series - really appreciated

Name:
Email:
URL:
Comments:

Remember me?

Shoot me an email when someone responds?

Enter this word:

Here:

GetBoyinked

Subscribe to Boyink.com