Three-Tier Static Content in ExpressionEngine: Approach A
Previously here on Train-ee.com I showed how simple two-tier static content could be presented using native ExpressionEngine functionality. This article builds on that approach to use EE categories to add another level of navigation to static content.
This is one of those times where the flexibility of EE really shows, as I quickly came up with three different ways to do this, using one, two and three templates respectively. In this post I’ll cover the single EE template approach, and follow this up with the more complex approaches.
I’ve again posted a working example of this approach. You could argue that this isn’t truly three-tier navigation since there is no 2nd-level (or category) content - but often times it seems that I’ve only needed to organize navigation, without actually needing content at the category level. This approach also builds nicely into the upcoming two-template route, so I think it’s worth covering.
For the purposes of this tutorial I’m going to assume you already have all the EE objects created for the two-tier navigation example. Starting from that point then, we need to:
- Add a category group
- Add categories to the group
- Assign the group to the static weblog
- Assign categories to entries
- Create a template to display the content
Creating the Category Group
Under Admin > Weblog Administration > Category Groups, click the “Create a New Category Group” button. Name the group - I’ve called mine “static”. At this point EE will tell you that in order to use the new group, you must assign it to a weblog, so let’s do that.
Assigning the Category Group
Under Admin > Weblog Administration > Weblog Management Assign the new category group to the static weblog by clicking the “Edit Groups” link for your static weblog. Choose your new category group and save your changes.
Under Admin > Weblog Administration > Category Groups click the “Add/Edit Categories” link, then the “Create a New Category” button. Add categories, descriptions can be optional at this point since in this approach they won’t be used. Since it’s April 12 and we still have snow here in West Michigan I’ve added three snow-related categories.
Assigning Categories to Posts
Since we have existing posts that now need to get assigned categories, use the EE Edit tab, and edit your static entries one by one, assigning them to the proper category, then saving your changes.
You could just edit the index template used in the two-tier navigation example, but since I wanted to leave that in place I created a new template called “three_tier_a” - here’s the text version, and here’s the working example.
The essential difference between this template and the two-tier approach is in how the left navigation is constructed. Rather than using a weblog:entries tag, I’ve used the exp:weblog:category_archive tag. The show_empty=“no” parameter might be important if you’ve created categories that don’t yet have weblog posts assigned to them - this parameter will keep those from appearing in the navigation.
That’s really all there is to this simple three (or 2.5) tier example.
- Simple - only one template needed
- Categories organize the navigation
- Since there are no category pages, URL’s stay simple without the EE category keywords
- Provides no category-level content.