Part of the EllisLab Network

Blog & News

Lisa Wess
Director of Community Services

Dissecting the Default Templates: The Weblog Entries Tag

Welcome back to Dissection Thursday, folks!  Today’s article is going to focus on the weblog entries tag, arguably one of the most important tag pairs in ExpressionEngine.  If this is your first time reading this series, then I recommend reviewing the first three articles: assigned variables, variables, paths, and weblog=, and the category heading tag pair.

We’ve often heard the weblog module referred to as a “data container”.  The reasoning behind this is simple - between custom fields, categories, and relationships, you can store and retrieve nearly any type of information.  But before we can run, we must first walk.  The default templates start off with a blog-like structure.  This isn’t because ExpressionEngine is a blog-only system, but because a weblog itself is an easy to understand medium for posting articles on one’s site and is widely recognized and understood.  By beginning with the typical blog layout, we can have a common starting ground.

Now we’ve come to the real guts of the index template - the main content area. The data itself is stored in the weblog module - remember, all of this can be done out of the box in the default installation!  The main content area is served by using the weblog entries tag.  This tag pair begins with an opening tag:

{exp:weblog:entries weblog="{my_weblog}" orderby="date" sort="desc" limit="15" disable="member_data|trackbacks"}

Now there is a lot going on here.  Let’s begin with a reminder on how to search for these items.  You want to search for the beginning of the tag - exp:weblog:entries.  There is a lot of information there to take in, so I recommend not getting ahead of yourself - just glance at the first link, until you have a reason to search further, that is!

From our previous articles, we understand just how important weblog= is, and that it is calling an assigned variable of {my_weblog}.  Great!

We discussed, in an earlier article, how parameters work.  All of those words, followed by the = sign, we now know are parameters, so we can look at the weblog entries parameters to find out what they do.  Since we see orderby= first, let’s have a look at what orderby= is for.  Here, in our default templates, it has a value of “date”.  This is a typical blog method of ordering entries, and if you leave off the orderby= parameter, then it will default to date.  However, you can use any of those values to over-ride the default to sort your data however you want. 

We next see sort=, which works with orderby= so that you can reverse the display should you wish. 

One sticking point we often see with folks coming into EE from another system is, “how to limit the display of articles”. Here, we see the answer - this isn’t done system-wide, but is done with the ultimate flexibility, right here as a parameter.  You can now use this tag to display different weblog data, with different limits, rather than being locked into a system-wide limit.

Lastly, we get to disable=, which deserves some special attention.  The weblog entries tag is the heavy-lifter in ExpressionEngine; it pulls out lots of data and sorts, orders and limits that data for you.  However, in any given weblog entries tag there may be information about the entries that you do not show and therefore does not need to be processed.  It is best, then, to entirely disable that data in this particular tag, to optimize the behavior and keep everything running fast.  So have a look at the disable= parameter.  Once we have gone through this entire tag, I’ll make sure to come back to this parameter in order to explain how to know which values to use.

Let’s summarize, then, what is in this article.  We have started, using the weblog entries tag, to pull our data out of the database and into the template for display.  We have not yet actually put any variables in to display anything; however, we’ve started with the necessary building block: the opening tag for the weblog entries tag pair. We have also told the tag pair how we’re going to want that data ordered, sorted, limited, and disabled.

Next week, we’ll get into the meat of the weblog entries tag, what goes between the tag pairs - those wonderful variables - so that we can actually display our articles.  See you then!