Here’s a “back to basics” tutorial for newcomers to ExpressionEngine - how to build a static portion of a website, with no plugins, extensions, or modules required.
While this has always been possible in EE, I think the popularity of Mark Huots Static Pages Module has mislead some folks into thinking that the module was required for presenting static content in EE.
Nothing could be further from the truth - and in fact there are some advantages to sticking with native EE functionality for static content.
This tutorial is meant in no way to disparage the Static Pages module - I’ve used it and do appreciate many aspects of it including the site-map based UI, the easy breadcrumbs and nice URL’s. I also appreciate the authors contribution to the EE community and will readily confess that his coding skills are on another plane from my own…
Having said that, using native EE code for building a static section of content has a number of advantages over the Static Page module. I’ll cover those after taking you through how to build a static content section using the native EE code approach. I do also want to note that there is an entry on the EEWiki regarding static content outside the Pages Module, but I felt it could be improved upon - especially for newcomers to EE.
OK - with the disclaimers out of the way let’s proceed. In the following tutorial I’ll show how to build a simple static section with a default Index page and some subpages. I’ve posted both a working example of this approach and a text version of the EE template being used.
For this native-EE static content approach you’ll need a new weblog, field group, content, and a new template.
Note on Links/URL’s
Here on Boyink.com “splaat” is my renamed EE index.php.
Weblog Setup
Field Group Setup
Content Entry
No worries if you enter the content out of order - you can always tweak the publish dates to push the Index content to be the oldest entry.
Template Coding
For the purposes of this tutorial, I’ve created a new template group and called it “static”. All we’ll need is the index template that EE provides by default. For reference, download the text version of my template. Copy/paste anything you need - just tweak for any path or name differences.
The template uses two weblog:entries tags—one to build the left navigation, and one to display the page content.
That’s really all there is to building a simple, two-level static section of content with ExpressionEngine. And this is just one approach - as with anything ExpressionEngine there are always multiple ways to achieve your goals.
Advantages
There are a few advantages of using this approach over the Static Pages module:
Next up - using EE categories to provide a third navigation layer.
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:
April 11, 2007
Wahoo!
That’s some good stuff. Looks plenty simple too. The UI of Pages is definitely nice, but it has it’s flaws.
April 11, 2007
Nice write-up. This is certainly a great way to do two tier navigation. And if you instruct your client on how to duplicate template groups it could even be three tier navigation
.
April 11, 2007
Whooboy - clients creating templates...not something I’ve done yet.
Nah - we can still use EE categories for 3rd level stuff and keep them out of the templates area. That’ll be the next writeup.
April 11, 2007
I’m looking forward to that, it sounds promising!
April 11, 2007
That is a good writeup
I am really interested in learning who to make 3 tier navigation as my next project involves… 3 tier navigation!
I wonder what the next installment Pages will bring though?
April 16, 2007
Very nicely explained. Thanks for the write-up and looking forward to part II!
April 17, 2007
Great write-up. This is how I’ve tackled this kind of basic static site content since I began building EE sites in 2004. I’ve never understood the benefit of the Pages module, though I appreciate it’s a good approach for many too.
April 17, 2007
Nice article and exactly how I’ve been doing really basic sites that people want to add content to themselves. I’ve tried the Pages moduel but it just didn’t feel right… one thing that has always bothered me about Huots work (and the guy is obviously a very talented coder) is the total lack of any doumentation.
April 21, 2007
I’m just working through this, and in case there are any other complete neophytes like myself plodding along, the following note. In the “Field Group Setup” section when you read:
“In the EE Control Panel, navigate to Admin > Weblog Administration > Field Groups and create a new field group.”
my install (v.1.5.2) does not have a “Field Groups” heading under Weblog Administration. It does have a “Custom Weblog Fields” which leads to “Field Groups”, with the possibility of creating new ones.
Just a momentary “whazzat?!” moment, but I thought I’d mention it anyway.
Thanks so much for these “static content” tutorials—a most helpful resource!
April 21, 2007
Thanks for the feedback David—I’ve updated the wording in that section in hopes of making things a bit clearer.
April 21, 2007
That’s fast! Thanks Mike.
I’ve been plugging away, and this is clearly in the “uber-nifty” category!
Clearly I have something to learn about URLs in EE, because when I click on the “Static Section Index” in this model, I get a 404, although the “subpages” display nicely.
FWIW, I’m working on this with a XAMPP localhost environment, the “path” to my “Static” blog is http://localhost/ee/index.php/static/
I get the strong sense this is worth persevering with!
April 21, 2007
You caught me in on lunch...
If you haven’t edited the “Static Section Index” link from the text template, you’ll need to as I’ve renamed my “index.php” to “splaat”. Your link should be, I think, “/index.php/static/”
May 13, 2007
This is quite nice, Mike. Thanks. I have a client who asked for something fairly similar a few days ago, and at the time my brain noodled around with something like this. Your write up saves me a bit of thinking and setup time
May 17, 2007
This is definitely the way to handle static content in EE. Great post. Thx.
June 19, 2007
Hi - still working through this tutorial: I am stuck… when i create a new template group does one have to change the two main tag at the start of the page? for example my main site group is SFV. I then want to create a
new “blog” section called News. My new template group is news…
so do i change:
{assign_variable:my_weblog="default_site"}
{assign_variable:my_template_group="sfv"}
to
{assign_variable:my_weblog="default_site"}
{assign_variable:my_template_group="news"}
in my news template page and then add this to get output:
exp:weblog:entries weblog="news"
i wanted to have mostly a static site expect for the first page which has “snippets” from News and snippets from Events which then leads to a static page which displays only one news item at a time.... with a more link to the other news posts.
thanks for all your help
June 19, 2007
OK - you’re actually going a bit past my tutorials as I didn’t use the assign:variable piece.
News and Event content also isn’t what I’d consider “static content”—it’s more dynamic, date-related content that is closer in functionality to how blogs function.
On the assign:variable declarations, those are simple text-replacements that let you more easily copy/paste templates then change the variable to work with a different weblog and path. You assign the variable once at the top of the template then reuse it everywhere else - so rather than “weblog="news" you’d say weblog="{my_weblog}".
If you’re new to EE I’d suggest removing them as they’re just adding a layer of complexity that might be confusing you.
It sounds like your home page will be a unique template that uses two weblog:entries tags - one to pull news and one to pull events. Within those tags you’ll code the paths (using the URL title type link) to the single-entry pages (and again being new to EE I’d suggest unique single entry templates for each).
Each single entry template will contain a weblog:entries tag, one pulling from news and one from events. The URL title path link will tell the weblog tag which post to pull.
July 05, 2007
Thanks for that. Is there a way that I can create a sub-menu for the navigation for these static pages, i.e.
About
- ... us
- ... the project
- ... the sponsors
Project
- Intro
- Details
- Summary
...
? Thanks for any advice!
July 05, 2007
Hi Stef - did you read on to the next tutorial?
September 07, 2007
This post has me wondering what other Expression engine plugins are really unnecessary, and possibly better off done with EE native capabilities. Maybe people got used to Wordpress where there are like a zillion plugins.
September 07, 2007
Oops forgot to subscribe to comments… tnx
Boink me of further boyink’s!!
Ideas then anyone of plugins that really aren’t needed?
September 20, 2007
Mike these tutorials are great - thanks!
Pretty sure Im overlooking something here though.
I keep seeing the index page content no matter which link I click on.
I copied the static_content_index.txt to eliminate any error I may have introduced however I get the same result. Im guessing it might have something to with this comment located under the page content section:
The “sort="asc" parameter ensures that, if no url-title is passed to this template by one of the subnavigation links (like a link from your main navigation bar), the Index content will be loaded.
Have I missed something?
Thanks
September 20, 2007
Hi Brett -
Are the links being generated correctly? Does the page url change, even though the same content is loaded? Did you change anything in the code - weblog name, etc.?
September 22, 2007
ok got it working - I missed the template group section. All good now
On to the next - thanks!
October 01, 2007
Excellent tutorial. Is there a way to have a menu on my main weblog automatically populated with each static section? I am creating one for each section of my weblog, but need the default template (the one featuring the home about archive contacts menu) to have a menu on it, and then a new weblog (section, in this case “static") is created, a menu item is automatically added.
Thanks in advance.
October 01, 2007
Not sure I completely understand the question - but if you’re looking for your top-level main navigation to be dynamic, and it’s based on weblogs, then no, there isn’t a “out of the box” way in EE that I know of.
You could probably write a query to do so, but IMHO in the time it’d take you to do that you could just update an embedded template that has your navigation in it with the new link.
I’ve never had a site where the top-level structure changed often enough to deserve looking into a more dynamic approach.
October 01, 2007
Whoa, that was quick
I am very new to EE and a complete coding newbie, so I may ask things the wrong way. I think that’s what I am looking for. Any links to tutorials showing how to embed and style a manually updated menu?
Thanks for your help. It took me a while to understand this tutorial but I made it work. Happy
October 01, 2007
Here’s a pretty good one:
EE Behind the Curtain Part One
October 01, 2007
Thank for everything!
December 18, 2007
It has taken me a long time to stumble upon this tutorial but I am very glad I made it finally.
Thank you, Mike
I am now going to work my way through them. I am hoping to find guidance on variables that can be entered within weblog entries such as {filedir_1} - where they are defined, what others there are and how to use them.
December 18, 2007
Hi Kip - glad you made it here. The best resource for the available variables within a weblog entries tag is the EE docs.