The Importance of Semantics: Static Pages
Over the last few weeks, since I began writing in our blog for your reading pleasure, I have gotten a few suggestions about what to write on. These articles are to help you, so .(JavaScript must be enabled to view this email address)
Before we continue, this article is going use terms from The Importance of Semantics, so you may wish to take a moment and review that article.
Last Week, I said we had completed the default URL handling, but you see, it doesn’t actually end there! Every site, including my own, has certain pages that are “static” in nature and would benefit from a simple URL structure. For example, almost every site has an About page. It would be really nice to easily add to and edit this type of content which is exactly what the Pages Module is for.
Pages makes managing “static” content very straightforward. A Page is identified by a few characteristics that set it apart from a standard channel entry.
- You decide the URI when you create the entry in the Publish form’s “Pages” tab.
- When creating the entry, you choose the template to use for displaying that entry.
How, then, do we take advantage of these custom URIs so that we can have our articles appear magically wherever we want? Well, read on!
First, create an entry and fill out the URI and template in the Pages tab. Now, instead of the URL Title or Entry ID, all that we have to do is visit the appropriate URL - that is, your standard URL, often the domain-name, with your URI.
So here is our basic channel entries tag, the power behind displaying all of this:
{exp:channel:entries channel="default_site" limit="10" disable="pagination"}
<h2>{title}</h2>
{body}
{/exp:channel:entries}
Now create an entry, and in the Publish form’s Pages tab enter “/about-us/” as the URI. We also have a template, let’s say “site/page” with the above channel entries code, so we choose site/page as the template.
All we have to do to visit that Page is go to:
http://example.com/index.php/about-us/
This special URI, which you defined in the Publish form, tells EE that it is a single-entry page and should use your specified template for display, just like we were doing when we used the template group and template name, only now at any URL you want.
And don’t forget that there is a Pages Quick Start Guide to help you with each step in setting this up.
This is really a built-in special exception to the standard URL handling, however, once you think of it as a “single-entry page at your own custom URL” I think that it will become clearer as to how useful and powerful this can be.





