typo icon

Category icons for Typo

Posted in Sun, 09 Jul 2006 14:36:00 GMT

I decided to see how easy it was to add category icons to my Typo install and it turns out to be pretty easy. Only some categories have icons now. They are shown if they exist otherwise they are skipped. The category icon will also appear in the table of contents when the page is a category page. When I migrate to Typo 4.0 these will become tag icons. This is a quick hack for now and should be cleaned up a bit.

Step 1 is to add the icons to the articles. Right now I just code a list of categories I have icons for in the helper method below but I should either put the list in a config setting or make a model for it. The modified files are:

  • app/helpers/articles_helper.rb: add an article_icons method to generate the icons given an article.
  • app/views/articles/_article.rhtml: add call to the new article_icons helper method.
  • app/views/articles/read.rhtml: add call to the new article_icons helper method.

Step 2 is to add it to the TOC if you have one. If you don't have one yet, you can follow the directions here. The modified files are:

  • app/controllers/articles_controller.rb: set @category instance variable in the category action.
  • app/helpers/articles_helper.rb: add a category_icon method to generate the icon given an category.
  • app/views/articles/_articles_toc.rhtml: add call to new category_icon helper method and pass it the @category instance variable if it exists.

I also created a category sidebar that uses icons instead of text names but found that it's really only useful if all your categories/tags have icons. If a reasonable percentage don't, having a bunch of default icons kind of defeats the purpose.

I'll post some code once it's been migrated to Typo 4.0 and has been cleaned up a little. I'm still not sure what's the best way to package mods that require changes to controllers, helpers and templates. My current thoughts are patches for controllers / helpers and either patches for Azure or instructions on how to mod your own templates. Let me know what you think.

del.icio.us:Category icons for Typo digg:Category icons for Typo reddit:Category icons for Typo spurl:Category icons for Typo wists:Category icons for Typo simpy:Category icons for Typo newsvine:Category icons for Typo blinklist:Category icons for Typo furl:Category icons for Typo fark:Category icons for Typo blogmarks:Category icons for Typo Y!:Category icons for Typo smarking:Category icons for Typo magnolia:Category icons for Typo segnalo:Category icons for Typo

no comments


(leave url/email »)

   Comment Markup Help Preview comment