Weblog Category Archive Listing

This tag is designed to let you list all of your weblog entries and have them organized by category.

{exp:weblog:category_archive weblog="weblog1"}

{categories}
<h3>{category_name}</h3>
{/categories}

{entry_titles}
<a href="{path=SITE_INDEX}">{title}</a><br />
{/entry_titles}

{/exp:weblog:category_archive}

This tag allows you to show your entry titles organized by category in a master archive that looks like this:

<h3>Category one</h3>
<a href="www.mysite.com/1/">title one</a>
<a href="www.mysite.com/2/">title two</a>
<a href="www.mysite.com/3/">title three</a>
<a href="www.mysite.com/4/">title four</a>
<a href="www.mysite.com/5/">title five</a>
<h3>Category two</h3>
<a href="www.mysite.com/6/">title one</a>
<a href="www.mysite.com/7/">title two</a>
<a href="www.mysite.com/8/">title three</a>
<a href="www.mysite.com/9/">title four</a>
<a href="www.mysite.com/10/">title five</a>
etc...

It shows the name of each category, and the weblog entry titles assigned to them. Note: Once you have hundreds of weblog entries, it might become cumbersome to use this tag on your page.

Parameters

backspace=

backspace="6"

Backspacing removes characters from the last iteration of the loop. For example, if you put a <br /> tag after each listed entry you'll have this layout:

Category one
<a href="www.mysite.com/1/">title one</a><br />
<a href="www.mysite.com/2/">title two</a><br />
<a href="www.mysite.com/3/">title three</a><br />
<a href="www.mysite.com/4/">title four</a><br />
<a href="www.mysite.com/5/">title five</a><br />
Category two
<a href="www.mysite.com/6/">title one</a><br />
<a href="www.mysite.com/7/">title two</a><br />

You might, however, not want the <br /> tag after the final item in each set. By adding backspacing you can remove it. Simply count the number of characters and spaces in the item you want to remove and add it to the tag. A <br /> tag has 6 characters, so you would do this:

{exp:weblog:category_archive weblog="weblog1" backspace="6"}

{categories}
<h3>{category_name}</h3>
{/categories}

{entry_titles}
<a href="{path=SITE_INDEX}">{title}</a><br />
{/entry_titles}

{/exp:weblog:category_archive}

That will produce code like this:

<h3>Category one</h3>
<a href="www.mysite.com/1/">title one</a><br />
<a href="www.mysite.com/2/">title two</a><br />
<a href="www.mysite.com/3/">title three</a><br />
<a href="www.mysite.com/4/">title four</a><br />
<a href="www.mysite.com/5/">title five</a>
<h3>Category two</h3>
<a href="www.mysite.com/6/">title one</a><br />
<a href="www.mysite.com/7/">title two</a>

The "backspace" parameter is only allowed if you are using the "linear" style. It is not applicable if you use the "nested" style for the display of the list.

orderby=

orderby="date"

The "order" parameter sets the display order of the entries. Setting options for this parameter include:

If this parameter is not set, it will default to ordering by the title.

sort=

sort="asc" sort="desc"

The sort order can be "asc" (ascending order or "oldest item first") or "desc" (descending order or "newest item first"). If you do not use a sort order the default is desc.

Note: The order of the categories will always be alphabetical. The only things the sort parameter changes is the order of the entries within each category.

status=

status="open"

The weblog status to which you would like to restrict display. You can choose multiple statuses using a pipe:

status="draft|reviewed|published"

Or exclude statuses using "not"

status="not submitted|processing|closed"

style=

style="nested"

There are two list "styles" for your categories: "nested" and "linear".

By default, the category list is displayed fully "nested" to show the parent/child hierarchy between the categories. It will display the categories as nested "unordered lists" and will automatically enclose the contents in <li> tags and nest them correctly to show the hierarchy.

The list can also be shown in a flat "linear" style.

For more information about how this option works see the parameter description on the Weblog Categories page.

weblog=

weblog="weblog"

This indicates the name of the weblog to which the categories are assigned. Only a single weblog may be specified since this is a category list for a specific weblog. The weblog parameter is required unless you only have a single weblog.

Variables

There are two variable pairs to delineate where the category markup starts/ends and where the title markup starts/ends.

categories

{categories}
<h3>{category_name}</h3>
{/categories}

The {categories} tag pair is the same as the one used in the regular weblog tag. See that page for specific information.

entry_titles

{entry_titles}
<a href="{path=news/entry}">{title}</a>
{/entry_titles}

The {entry_titles} tag pair allows you to list the entries within a category. There are two variables available for use within the tag pair:

{title}

This variable is replaced by the title of the entry.

{path=template_group/template}

The path (template_group/template) where you want to show the entries. This is typically used within a standard HTML link tag:

<a href="{path=weblog/index}">{title}</a>

You can also use SITE_INDEX in your path to point to your main site index page. If you show your blog on your home page, using SITE_INDEX is preferable since it will make the URL cleaner.

<a href="{path=SITE_INDEX}">{title}</a>