Don, if you need to look up more than one category name, add this code in config.inc.php (should run every time the template is loaded):
Code: Select all
$all_cats = serendipity_fetchCategories('all');
$id_to_name = array();
foreach ($all_cats as $cat) {
$id_to_name[$cat['categoryid']] = $cat['category_name'];
}
$catnames = array('names' => $id_to_name);
$serendipity['smarty']->assign('catnames', $catnames);
Now you can access $catnames in your entries.tpl; since it's an array with a nested array, you can even use {pickKey array='$catnames' key='$template_option.catid'}.
If you know the particular ID you like, you can just use $catnames.names[10].
If you'd like to be able to access more category information, you can either make and populate an additional array (like $cat_parents), or try something like this:
Code: Select all
$all_cats = serendipity_fetchCategories('all');
$id_to_data = array();
foreach ($all_cats as $cat) {
$id_to_data[$cat['categoryid']] =
array('category_name' => $cat['category_name'],
'parentid' => $cat['parentid']
);
// You can also get:
// category_icon
// category_description
// authorid
// category_left
// category_right
}
$catdata = array('data' => $id_to_data);
$serendipity['smarty']->assign('catdata', $catdata);
Unfortunately, getting at the data becomes more difficult. If you know the category ID, you need $catdata.data[10].category_name. You need to do something like:
Code: Select all
{capture assign='thecat'}
{pickKey array='$catdata' key='$template_option.catid'}
{/capture}
<span>Category {$thecat.category_name}'s parent: {$thecat.parentid}.</span>
Hope that does what you need; I haven't had a chance to test any of it.