Help - Search - Members - Calendar
Full Version: Archive by Category in Main Index Page
Movable Type Community Forum > Additional Resources > Tips and Tricks
RayTBrown
I have hunted high & low for this, but I can't seem to find how to include a section in the sidebar that lists (w/link) an "Archive by Category" on my index page.

I've seen it done on many sites and would like to duplicate this.  Can someone point me in the right direction?

Thank you,

Raymond
Joni
You mean one that displays:

[sidebar]

Apples
Oranges
Pears
Lemons

?? And clicking on the category takes you to a page where all your posts for that category appear?

If that is what you want, this is the code:
CODE
<MTArchiveList archive_type="Category">
<a href="<$MTArchiveLink$>"><$MTArchiveTitle$></a> (<$MTArchiveCount$>)<br /></MTArchiveList>


Notice this piece of code above:
CODE
(<$MTArchiveCount$>)


Is the comment count.  Include it and your categories are listed like this:

Apples (4)
Oranges (2)
Pears (0)
Lemons (1)

Hope this helps!

Joni
http://www.jonielectric.com


[/CODE][CODE]
maddy
You have a couple of options, here. Both should give you the same result. smile.gif
CODE
<MTCategories>
<a href="<$MTCategoryArchiveLink$>"><$MTCategoryLabel$></a><br />
</MTCategories>
or
CODE
<MTArchiveList archive_type="Category">
<a href="<$MTArchiveLink$>"><$MTArchiveTitle$></a><br />
</MTArchiveList>
I use the second option, and include the correct tag to display how many entries are in each category:
CODE
<MTArchiveList archive_type="Category">
<a href="<$MTArchiveLink$>"><$MTArchiveTitle$></a> (<$MTArchiveCount$>)<br />
</MTArchiveList>
If you want to display categories that don't have entries assigned yet, use the MTCategories option, but add in show_empty="1" to the tag, that is
CODE
<MTCategories show_empty="1">
- but be aware that this will generate broken links for those categories until they have entries in them.  

I hope that helps! smile.gif Post back if you have any more questions.
maddy
I took too long to type! smile.gif
RayTBrown
Thank you so very much.  That is EXACTLY what I was looking for.  I am especially grateful for the quick response.

Raymond biggrin.gif
catcon
Joni and Maddy,

I had to jump on and say thank you as well. I love this forum! Evidently, there are plenty of new folk who have the same questions as mine and I always find what I need just by searching.

thanks again!
connie
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.