Creating a Better Category Archives Template

user-pic
Vote 0  

Filed:

 
Using the tag BlogCategoryCount, we can determine if the blog is using categories or not. This allows me to put a Category Widget in a column, and auto-hide it if there are no categories created.

The default Page Listing Widget uses this logic. I do not know why the default Category Archives template does not. You can check out the code after the jump.
<mt:IfArchiveTypeEnabled archive_type="Category"> <mt:If tag="BlogCategoryCount"> <div class="widget-archive widget-archive-category widget"> <h3 class="widget-header">Categories</h3> <div class="widget-content"> <mt:TopLevelCategories> <mt:SubCatIsFirst> <ul> </mt:SubCatIsFirst> <mt:If tag="CategoryCount"> <li><a href="<$mt:CategoryArchiveLink$>"<mt:If tag="CategoryDescription"> title="<$mt:CategoryDescription remove_html="1" encode_html="1"$>"</mt:If>><$mt:CategoryLabel$></a> <mt:Else> <li><$mt:CategoryLabel$> </mt:If> <$mt:SubCatsRecurse$> </li> <mt:SubCatIsLast> </ul> </mt:SubCatIsLast> </mt:TopLevelCategories> </div> </div> </mt:If> </mt:IfArchiveTypeEnabled>

Email to a friend

Anonymous comments are always moderated, please sign in and join the discussion. Create an account for a user profile and community features. Please read our comments policy.

Leave a comment

Poll

Do you like the toolbar at the bottom of this blog?

View results

View & Download PDF


View our support community!

About This Blog

Ken Edwards (and hopefully other project members) will be blogging here — a place to keep up on what is happening on the BG Views project. You will find bits of code, project updates, and random technical information aimed at confusing the hell out of you. More »

Subscriptions

Mobile Edition

Mobile EditionAccess the BG Views Developer Blog on your iPhone or other mobile device. Read more about our mobile site »
Powered by Movable Type 4.34-en

 

Also powered by:

  • Caffeine (Dr. Pepper)
  • Cup Cakes (Hostess)
  • Pizza (Pisanello's)