Published by Mijingo

movie icon image

ExpressionEngine How-to Articles

Topics range from beginner to advanced, but are all born out of real world, professional, day-to-day use of ExpressionEngine. Need more information? Get training videos and ebooks on ExpressionEngine from Mijingo.

ExpressionEngine Tags Primer

So, EE tags. They’re the things that start and end with curly braces and that you use all over your EE templates to make your content appear. This short tutorial will give you an overview of EE tags, the different kinds and how they’re made.

There are three basic types of EE tags.

  • Tag Pairs
  • Tag Pair Variables
  • Tag Variables
Tag Pairs

The most common tag pair you’ll use is the one for displaying your weblog entries in a template, so we’ll use this one as a example.

{exp:weblog:entries}

content here

{/exp:weblog:entries}

As you can see, it’s called a tag pair because it is made up of two tags; the first tag opens the pair and the second closes it using a / before the tag name. The opening tag of a pair also tags parameters. Parameters let you more narrowly define what the tag pair should output. Here’s a typical scenario using the weblog entries tag pair.

{exp:weblog:entries weblog="articles"}

content here

{/exp:weblog:entries}

The weblog parameter tells EE from which weblog to pull the content. This is a required parameter to use this tag pair. But there are some optional parameters, like limit, disable and category. A weblog entries tag pair with multiple parameters would look like this:

{exp:weblog:entries weblog="articles" limit="10" category="35"}

content here

{/exp:weblog:entries}

Visit the official EE documentation for a complete list of the parameters for the Weblog Entries tag pair.

Tag Pair Variables

With our tag pair all set, we need to focus on using Tag Pair Variables inside of the tag pair to make our content appear. Each tag pair you use (weblog entries, categories, etc) will have a set of supported variables. Only those variables will work inside of the tag pair.

{exp:weblog:entries weblog="articles" limit="10" category="35"}

{title}<br />

{/exp:weblog:entries}

This tag pair will display the entry title for the last 10 entries in category 35 in the articles weblog. You end up with something like this:

	Sample blog entry 1<br />
	Sample blog entry 2<br />
	Sample blog entry 3<br />
	Sample blog entry 4<br />
	Sample blog entry 5<br />
	Sample blog entry 6<br />
	Sample blog entry 7<br />
	Sample blog entry 8<br />
	Sample blog entry 9<br />
	Sample blog entry 10<br />

Also supported inside of the weblog entries tag pair are any of the custom fields you create in EE. You simply wrap the field_name in curly braces and place it inside the tag pair.

{exp:weblog:entries weblog="articles" limit="10" category="35"}

{title} - {my_custom_field}<br />

{/exp:weblog:entries}

You can find a complete list of weblog entries tag pair variables in the EE documentation. While they weren’t covered in this primer, you should also read up on Conditional Variables and Variable Pairs for the weblog entries tag pair.

Tag Variables

Tag Variables are any single tag which exist outside of a tag pair. The primary example is the dynamic variable that you can create and assign in a template.

	{assign_variable:my_name="Ryan Irelan"}

We just created a new tag variable called {my_name} and assigned it the value of “Ryan Irelan.” Now, anywhere I use that variable in the same template, my name will display.

EE also provides several tag variables that are global (meaning, you can use them anywhere, on any EE template). Useful variables like { homepage } will display the website’s homepage (as set in the control panel), { current_time } will display the current time and { site_name } will display the name of the website. The EE documentation has a full list of all the global tag variables.

Posted on Dec 30, 2008

Filed Under: How-To, Getting Started with ExpressionEngine,

Ryan Irelan
About Ryan Irelan

Ryan Irelan is the Technology and Development Director at Happy Cog, a web design and development firm. He is a noted ExpressionEngine expert, having created a wildly popular video training series on ExpressionEngine. Additionally, Ryan is the publisher of EE Insider, a well-known news and information site for the ExpressionEngine community. In his spare time, Ryan is the production director of A List Apart Magazine, which is one of the most popular ExpressionEngine-powered sites on the web. Recently, Ryan published a book on ExpressionEngine 2 called "ExpressionEngine 2: A Quick-Start Guide."