I probably have this written incorrectly, but... how do I get this info, namely the $category name at the end, to be accessible via a template variable?
Like how $forumbits is pulled from a function into the forum templates.
PHP Code:
function get_categories($cat_id = 0)
{
global $vbulletin, $stylevar, $vbphrase, $show, $atlas_config, $site_template;
global $cat_cache, $cat_parent_cache, $new_image_cache, $subcat_ids;
$cattable_width = ceil((intval($atlas_config['cat_table_width'])) / $atlas_config['cat_cells']);
if ((substr($atlas_config['cat_table_width'],-1)) == "%")
{
$cattable_width .= "%";
}
if (!isset($cat_parent_cache[$cat_id]))
{
return "";
}
$visible_cat_cache = array();
if (empty($visible_cat_cache))
{
return "";
}
$total = sizeof($visible_cat_cache);
$table_columns = (intval($atlas_config['cat_cells'])) ? intval($atlas_config['cat_cells']) : 2;
if ($total <= $table_columns)
{
$table_rows = 1;
}
else
{
$table_rows = $total / $table_columns;
if ($total >= $table_columns AND !is_integer($table_rows))
{
$table_rows = intval($table_rows) + 1;
}
}
$categories = '<table width="'.$atlas_config['cat_table_width'].'" border='0' cellpadding='0' cellspacing='0'><br /><tr><br /><td valign='top' width="'.$cattable_width.'" class='catbgcolor'><br />';
$categories .= '<table border='0' cellpadding="'.$atlas_config['cat_table_cellpadding'].'" cellspacing="'.$atlas_config['cat_table_cellspacing'].'"><br />';
$count = 0;
$count2 = 0;
foreach ($visible_cat_cache AS $key => $category_id)
{
$categories .= '<tr><br /><td valign='top'><br />';
$is_new = (isset($new_image_cache[$category_id]) AND $new_image_cache[$category_id] > 0) ? 1 : 0;
$num_images = (isset($cat_cache[$category_id]['num_images'])) ? $cat_cache[$category_id]['num_images'] : 0;
$subcat_ids = array();
get_subcat_ids($category_id, $category_id, $cat_parent_cache);
if (isset($subcat_ids[$category_id]))
{
foreach ($subcat_ids[$category_id] AS $val)
{
if (isset($new_image_cache[$val]) AND $new_image_cache[$val] > 0)
{
$is_new = 1;
}
if (isset($cat_cache[$val]['num_images']))
{
$num_images += $cat_cache[$val]['num_images'];
}
}
}
if (defined("SHOW_RANDOM_IMAGE") AND SHOW_RANDOM_IMAGE == 0 OR defined("SHOW_RANDOM_CAT_IMAGE") AND SHOW_RANDOM_CAT_IMAGE == 0)
{
$random_cat_image_file = "";
}
else
{
$random_cat_image_file = get_random_image($category_id, 0, 1);
}
$this->registry = array (
'cat_id' => $category_id,
'cat_name' => format_text($cat_cache[$category_id]['cat_name'], 2),
'cat_description' => format_text($cat_cache[$category_id]['cat_description'], 1),
'cat_hits' => $cat_cache[$category_id]['cat_hits'],
'cat_is_new' => $is_new,
'lang_new' => $vbphrase['new'],
'sub_cats' => get_subcategories($category_id),
'cat_url' => $vbulletin->session->url(ATLAS_ROOT_PATH."categories.php?".URL_CAT_ID."=".$category_id),
'random_cat_image_file' => $random_cat_image_file,
'num_images' => $num_images);
eval('$categories .= "' . fetch_template('atlas_category_bits') . '";');
$count++;
$count2++;
$categories .= '</td><br /></tr><br />';
if ($count == $table_rows AND $count2 < sizeof($visible_cat_cache))
{
$categories .= '</table><br /></td><br />';
$categories .= '<td valign='top' width="'.$cattable_width.'" class='catbgcolor'><br />';
$categories .= '<table border='0' cellpadding="'.$atlas_config['cat_table_cellpadding'].'" cellspacing="'.$atlas_config['cat_table_cellspacing'].'"><br />';
$total = $total - $count2;
$table_columns = $table_columns - 1;
/*if ($total <= $table_columns AND $table_columns > 1)
{
$table_rows = 1;
}
else
{
$table_rows = $total / $table_columns;
if ($total >= $table_columns AND !is_integer($table_rows)) {
$table_rows = intval($table_rows) + 1;
}
}*/
$count = 0;
}
}
$categories .= '</table><br /></td><br /></tr><br /></table><br />';
return $categories;
}