February 26, 2004

Category Archive Pages

The tips in this tutorial are designed around the templates for MT 2.661 and earlier versions.

Once you have set up category archiving, the next step is to customize the category archive display pages. The default Category Archive Template that comes with Movable Type lists the whole entries (not excerpts), doesn't tell the viewer what category she is actually viewing, and has no intuitive link back to the home page. We'll address these issues here.

1. Listing excerpts instead of full entries. You may want to keep the archives as is, with full entries. But if you have few categories and lots of entries you will soon have very large and long category pages. Changing to excerpts instead of the full entries is easy. Open up the template editing window for Category Archives Template. Find the following code:

<$MTEntryBody$>

<MTEntryIfExtended>
<$MTEntryMore$>
</MTEntryIfExtended>

Replace the above code with the following:

<$MTEntryExcerpt$> </$MTEntryExcerpt$><br />

Have the title of your excerpt be a hyperlink to the full entry. To do this, replace the following code on your Category Archives Template:

<h3 class="title"><$MTEntryTitle$></h3>

with

<h3 class="title"><a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a></h3>

2. What category is this? There are lots of ways to list the category you are in on the category page. All you have to do is add the following code somewhere on the Category Archive Template page:

<$MTArchiveTitle$>

To show the category category in the title banner, change your banner div section like so:

<div id="banner"> <h1><a href="<$MTBlogURL$>" accesskey="1"><$MTBlogName$></a></h1> <span class="description"><$MTBlogDescription$></span> </div>

to

<div id="banner"> <h1><a href="<$MTBlogURL$>" accesskey="1"><$MTBlogName$>: <$MTArchiveTitle$></a></h1> <span class="description"><$MTBlogDescription$></span> </div>

3. A nav link back home. If your website visitor clicks on the title of your weblog, MT should direct her back to your home page. But not everyone knows to do that. If you would like to add a more explicit link back home (see here for an example, with little directional arrows, here's the code (right after the container and blog div tags).

<div id="container">

<div class="blog">

<h3 class="title"><a href="<$MTBlogURL$>" accesskey="1"> &laquo; Home </a></h3><br><br>

You can combine a home link and a category title like so:

with this code:

<h3 class="title"><a href="<$MTBlogURL$>" accesskey="1"> &laquo; <$MTBlogName$> Home &raquo; </a> <$MTArchiveTitle$></h3><br />

Links for further category archive customization:

Brad Choate's Next/Previous Category Plugin
MT Support Forum Thread on Category Images
MT Wiki on Category Images
Different templates for different category archive pages - from Stepan Rhia


Has this tutorial been helpful? Please consider linking to Learning Movable Type at http://www.learningmovabletype.com/ . Thanks!

Trackback

If you would like to send a trackback
please use the following URL: http://www.learningmovabletype.com/cgi-bin/mt32/mt-tb.cgi/183

» Customizing the Category Template for Movable Type from How To Blog
Finally! An article that will help me modify my category archives. Right now, the default template for your category archive in Movable Type 3.0 lists the entire entry of EACH article in that category. If you have a lot of...[read more]

Tracked: July 24, 2004 07:14 PM

Comments

As a newbie to Moveable Type, I was able to follow your instructions to display Categories on my blog. Thanks. However, there is no display of the number of items under each category. Help.

Posted by: KP at March 4, 2004 11:36 AM

Now my question for the category archiving and changing it to excerpts.

Is there anyway to make it an excerpt but be able to see thee full thing if you want to. Basically make it an excerpt but be able to click on it and see all of it?

I hope this is clear.

Posted by: Andrew at March 12, 2004 09:30 AM

The title of the entry over the excerpt is actually a link to the full entry. If you want to see the excerpt turn into a full entry on the same page (versus opening to a new page) you can do that with PHP. I don't know how to do that, but you can ask on the MT Support Forum.

Posted by: elise at March 12, 2004 04:14 PM

THANK YOU for the great resource you have here!! I only wish I had found it earlier! :)

I have a similar question to one above regarding the excerpts having links to the entry.

I made the changes you describe to show excerpts instead of the full entry, but for some reason, my excerpt title is not a link to the full entry. The link to the full entry is actually in the "posted by" section - and it's the timestamp.. (not very intuitive to my users).

Can you please provide info on how to make the excerpt title a hyperlink?

I'm assuming I have put this:

$MTEntryPermalink$

Somewhere in this code you've provided above.

Am I correct in reading that I should have replaced the original 4 lines of code w/ the two you provided?

Thanks again!!


Posted by: Marc at March 16, 2004 08:12 AM

Andrew and Marc, I've added the instruction of how to turn the excerpt title into a link to the full entry. Thanks for bringing this to my attention.

Posted by: elise at April 9, 2004 11:58 PM

I noticed in the ACP category set-up there is a field for category description. Is there a way to have this appear on my category archive pages (on both my photo albums and regular blog)?

Posted by: Tij at June 2, 2004 08:47 AM

Tij - See the MT Manual section on category tags - http://www.movabletype.org/docs/mtmanual_tags.html#categoryrelated%20tags

Posted by: elise at June 2, 2004 09:06 AM

Comments are now closed for this entry.


Email to a friend

Email this article to:


Your email address:


Message (optional):