Starting on the Products templates.
In this chapter of the Building an ExpressionEngine Site Series, we’ll begin to code the Products section of the site—getting the Products index page in place, updating the main navigation, and getting the Section Overview text published. This new page will display the category content we created and defined in Chapter 8.
Creating the Product Index Template
To create the Products Index template we’ll copy one of our existing templates as a starting point, then tweak it to suit:
Editing the Product Index Template
Now we need to tweak the template to make it show Product Categories rather than About content. (Note - a text version of the completed template is included further down in this chapter):
Updating the Main Navigation Template
The Main Navigation template needs to be updated so it has the logic for this new page. Find the template in the template group that holds all of your embedded templates, and copy the list item for the about tab, paste it over the existing Products list item, and then update the code in the EE conditional, the page it’s linking to, and the link text.
Here is the text version of my updated Main Navigation template: chapter_9_main_nav.txt
Getting There
Once you save the changes to your main nav template, bring up your site in a web browser. You should be able to navigate to the Products section, the main navigation tab should highlight correctly, the page title should be correct, but the page content should be blank like my screen capture here.
Section Intro
Let’s get the section intro in place now. In your “Miscellaneous Content” weblog and create a new post, making sure the url title is “products”. Publish your new entry, refresh your Products page, and your section intro text should appear next to the search box.
The Category Listing
OK - now that the shell of the Products page is in place let’s get to the fluffy nougat center. This index page needs to list all of our Products categories along with the description. The EE tag for this is the weblog:categories tag. The code needs to go in the “left_side” div where the previous weblog:entries tag was.
Here’s a text version of the updated Products Index template: chapter_9_products_index.txt.
Looking at the weblog:categories tag here’s what’s happening:
I’ve just put placeholder links in - as we have not yet developed the category template that this page will link to. Note that the category_description field does not return, like weblog fields can, with XHTML formatting applied—hence the need for adding the p tags for proper markup.
Chapter Results
Here then is our rendered Products Index page, showing the correct title, section intro, and listing our categories and descriptions.
In Chapter 10 we’ll improve this page by adding images for each category, and we’ll create the category template that each category listing will link to.
On to Chapter 10.
Back to Chapter 8.
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:
October 05, 2007
C-o-o-l… I think this installment puts you ahead of schedule.
The tutorials going deep into need to know/know-how for Expression Engine now.
Have a great weekend!
October 05, 2007
Thanks for these tutorials...I’m new to EE and this series is getting me up to speed quickly!!!
November 14, 2007
I downloaded and unzipped the plugins, uploaded to the correct folder (by the way, one was already installed), changed my script, but got:
“Error
The following tag has a syntax error:
{exp:imgsizer:size}
Please correct the syntax in your template.
November 14, 2007
Hi David - I’m assuming you’re actually working on Ch 13? If so please comment over on that entry so as to minimize the confusion.
Syntax errors are usually typos or cut and paste errors - be sure to use the .txt version of the latest_products templates that I posted.
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.