Category ID known - how to fetch category name?
Posted: Thu Feb 21, 2008 4:58 pm
In my config.inc.php file, I am assigning category IDs to a template variable using Garvin's idea of:
So now I have $template_option.cat_assigned available. From index.tpl, how can I now fetch the category name for that ID so I can display the name instead of the ID?
Code: Select all
if ($serendipity['GET']['adminModule'] == 'templates') {
$all_cats = serendipity_fetchCategories('all');
$categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED);
$catsel = array();
foreach($all_cats AS $cat) {
$catsel[$cat['categoryid']] = str_repeat(' ', $cat['depth']) . $cat['category_name'];
}
}
........
array(
'var' => 'cat_assigned',
'name' => 'My category',
'type' => 'select',
'default' => '',
'select_values' => $catsel
),