Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-20-2008, 07:47 PM
WarriorDL's Avatar
WarriorDL WarriorDL is offline
 
Join Date: May 2003
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Function info to a template?

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) ? 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 == 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_id01);
        }
        
        
$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;

Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:15 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04713 seconds
  • Memory Usage 2,690KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (12)post_thanks_box
  • (12)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (12)post_thanks_postbit_info
  • (12)postbit
  • (12)postbit_onlinestatus
  • (12)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete