Create an Archive Page with TXP

08/24 '09

Since it wasn’t possible to use valid nested lists for the markup, I updated the code to use a definition list instead.

Using the power of <txp:if_different> you can create a very powerful article archive page in Textpattern. The goal of this 3 step process is to create an article archive page that organizes the articles by year and then month, all without using a plugin.

Step 1: Create an Archive List Form

Form Name: archive.list

<txp:if_different>
  <dt class="year"><txp:posted format="%Y" /></dt>
</txp:if_different>
<txp:if_different>
  <dt class="month"><txp:posted format="%B" /></dt>
</txp:if_different>
  <dd><a href="<txp:permlink />"><txp:title /></a>
  <txp:posted format="%h. %e" /></dd>

Step 2: Create an Archive Page

Page Name: Archive

<dl class="archive-list">
  <txp:article_custom form="archive.list" section="archive" />
</dl>

Be sure to replace section="archive" with the name of your default article section.

Step 3: Create an Archive Section

  1. Go to the Presentation tab and choose Sections from the sub tabs.
  2. Type in the name of the section you’d like and press Create. For this example we are using “Archive”.
  3. Scroll down to the Section name you just created and select the page that you created in the Uses Page: select box. For this example we are using “Archive”.
  4. Press Save.

Preview

Navigate to your newly created section to see how it all looks. With a little CSS and creativity you can make some interesting archive pages without any need for a plugin.

Check out my Archive page to see what I came up with.