Hi,
I'm using the K2 Content Module to display a list of recent items on my homepage (from mulitple categories). I would lke to add a small icon to each post to display which catgory they have come from.
I thought of doing so via a number of methods, including using a switch-case or if/else statement in the 'default.php' template to work out which category the article is in and change the icon based on a that, although that seems too rigid in it's structure (what if i add new sub categories etc.). I thought of also doing something similar with css, and adding the category alias to the list item and setup a bunch of css rules to display the correct icon, but that has the same problems of the first idea...
My final idea was to use the power of K2 to workout which category each article is from and simply use the 'Category Image' that you can upload when you create a new Category. My content is separated out into lots of sub and sub-sub categories, so in a 'best case' scenario, the script would also look back through the inheritence to parent categories and check for an override image (if the sub-cat has no image supplied, but it's parent does, use that image, if not then check it's parents parent for a cat-image etc),
This seems the most logical option.. however, I am not good enough at PHP or at deciphering code to workout which utilities/objects/propeties i'd need to use to achieve this.
it seems in the default.php I can access things such as:
$item->categoryname;
$item->categoryid;
$item->categoryalias;
$item->image;
I tried using
K2Helpers::getCategoryImage($image, $params);
but I don't know what I should be using for the parameters for such a function are (or how to implement the parent category checker that I'm looking to achieve)
Any help would greatly be appreciated.
Thanks.