The Importance of Semantics
As many of you know, I’ve been obsessively refreshing and answering questions on these forums since May, 2004. Over the course of 3 years one is bound to identify patterns of questions. Now that I have the keys to the kingdom I can try to impart some of those tidbits of wisdom that I have accumulated.
If someone were to ask me: “what is the hardest thing to learn about EE?” I would have to say that the biggest hurdle is having that “light-bulb moment” about how ExpressionEngine knows when to deliver information, and what information to deliver.
I have seen this question in thousands of forms, and some of the ways people overcome this are mind-boggling. I’ve seen it all, from a template made per article (can we say “painful”?!) to those of you who have had that light-bulb moment and go whole hog with it, creating a single monster template that “does it all.”
Human beings: we love extremes!
But neither of those two extremes are needed in ExpressionEngine, and if every person new to EE understood how the URL combines with the weblog entries tag to dictate what information is shown and when, then that hurdle would suddenly lower itself and that “light-bulb” moment might occur that much sooner. So, how about we commence exploring some terminology that you’ll need to learn to really grok EE. These terms will help you not only to build templates, but to communicate with your EE peers on more common footing, and to understand some of the terms we’ll use if you require technical support down the line.
Unfortunately, for everyone reading, you get subjected to one of my own personal favorite subjects: cats and dogs.
When coming into ExpressionEngine, there are several new terms to understand as they will create the groundwork for all of the default behavior.
Here we’ll focus on the {exp:weblog:entries} tag in its most basic form:
{exp:weblog:entries weblog="default_site" limit="10" disable="trackbacks"}
<h2>{title}</h2>
{body}
{/exp:weblog:entries}
There are several ways that you might visit a template that contains this code, and the URL that you visit it at is what will define what information is displayed. For this post, we’ll concentrate on the difference between a “single-entry page” and a “multi-entry page”
Let us say that you have 20 weblog entries. All of these entries are located in a weblog with the short-name of “default_site”.
We’re going to display these entries in the “index” template of the “site” template group, which will contain just the aforementioned code.
Now, let us visit that template directly:
http://example.com/index.php/site/index/
And you will see the last 10 entries (limit=“10”) sorted by date posted (see sort= and orderby=, but right now we are using the defaults). We refer to this as a “multi-entry page”.
Say that we wish to see, instead of all 10 articles, only 1 article, by URL title. This is what we refer to as a “single-entry page”. Say we have an entry with the URL title of “raining cats and dogs”, append that to the end of the URL:
http://example.com/index.php/site/index/raining_cats_and_dogs/
Here we can see how segment 3 contains a URL title, so the weblog entries tag that we have above knows that you want to display only a single entry. In this scenario, you could also use several “single-entry page” features including related categories mode, entry hit tracking, comment display, and comment form.
Alternatively, you could reference “raining_cats_and_dogs” by its entry id. Assuming it was the second entry ever entered:
http://example.com/index.php/site/index/2/
There is one important parameter that I want to mention here, that many people overlook in building their sites, and that is dynamic=“off”. This parameter, used in our above code:
{exp:weblog:entries weblog="default_site" limit="10" disable="trackbacks" dynamic="off"}
<h2>{title}</h2>
{body}
{/exp:weblog:entries}
tells that weblog entries tag to ignore the URL. If you then use any of the previous example URLs, you will still get the last 10 entries in default_site, not limited by the URL title.
. . . and that concludes this article. The future will contain more articles of this nature, all of which will build on the concepts here, since ExpressionEngine itself is built around these concepts.
So get those computers warmed up and get ready to rock!


