Help - Search - Members - Calendar
Full Version: Individual Archive Templates by Category
Movable Type Community Forum > Additional Resources > Tips and Tricks
birdahonk
I've only been able to find one thread that addresses my problem, but the solution ended up taking off in a different direction... so here I go.

I'm trying to create 2 different Individual Entry Archive Templates. One will be used for one specific category, Books, where I will use the MTAmazon tags to display attributes of books. The other template will be for all other entries.

I want individaul entry pages for entries assigned to the "Books" category to appear using a different template that the individual entry pages for the other entries in other categories.

Basically, all entries in all categories will use the generic individual entry layout, but those that are in the "Books" category will use a different template to display Amazon book data.

AND... to take it a bit further, does anyone know how I would accomplish the same thing with the Category Archive Templates? For example, all of the category archive pages (which show all entries in a particular category) would use the generic page layout, BUT the category archive page for the category "Books" would use a different template.

If anyone can help me here (or point me to another thread that may address this using different terminology), I would greatly appreciate it. Thanks.
markpasc
If you want to have each entry on a different page, you're pretty well stuck with Individual Entry Archives; you can't control what files are written well enough to do it with Category Archives.

But you can do this: use one Individual Entry Archive template and the Compare plugin to change up the content depending on if the category is Books or not. If the MTAmazon data block is the only difference between the templates, do something like:

CODE
... <h3><MTEntryTitle></h3>

<MTIfEqual a="Books" b="[MTEntryCategory]">
<MTAmazon ... >
</MTIfEqual>

<MTEntryBody> ...

If they're really, really different, I would put them in Template Modules and call them from the real Individual Archive Template:

CODE
<MTIfEqual a="Books" b="[MTEntryCategory]">
<MTInclude module="Individual archive: Books">
</MTIfEqual>
<MTIfNotEqual a="Books" b="[MTEntryCategory]">
<MTInclude module="Individual archive: Normal">
</MTIfNotEqual>
birdahonk
Thanks! It looks like this will do the trick. I'll give it a shot.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.