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

Reply
 
Thread Tools Display Modes
  #1  
Old 02-11-2010, 01:57 PM
Sarcoth Sarcoth is offline
 
Join Date: Mar 2006
Location: Huntsville
Posts: 521
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Trying to understand array's and rendering

So, I'm trying to convert my mod over to vB4 completely. I have most of it worked out, but now I'm trying to make it easier for the users to update the fields and titles they want to use. In the current version, the user has to go around and update the fields and titles they want to use in multiple places. I want to make it so they only have to do it once. Eventually, I want to make it so they can do it from a vB options page, but I'm taking baby steps. I want to get the variables working first. So, here is what I've done.

PHP Code:
//First area is where they set their fields to use and titles//
$field1st 'field7'$title1st "Status"//1st column
$field2nd 'field8'$title2nd "Character Name"//2nd column
$field3rd 'field9'$title3rd "VG Char ID"//3rd column
$field4th 'field11'$title4th "Character Race";  //4th column
$field5th 'field12'$title5th "Adventure Class"//5th column
$field6th 'field13'$title6th "Adventure Level"// 6th column
$field7th 'field14'$title7th "Crafing Class"//7th column
$field8th 'field15'$title8th "Crafting Level"// 8th column

//Second area is where I convert everything to an array//
$columns = array(
    
'column1' => $field1st,
    
'title1' => $title1st,
    
'column2' => $field2nd,
    
'title2' => $title2nd,
    
'column3' => $field3rd,
    
'title3' => $title3rd,
    
'column4' => $field4th,
    
'title4' => $title4th,
    
'column5' => $field5th,
    
'title5' => $title5th,
    
'column6' => $field6th,
    
'title6' => $title6th,
    
'column7' => $field7th,
    
'title7' => $title7th,
    
'column8' => $field8th,
    
'title8' => $title8th
);

//This is what I use to render the columns array into the template//
$templater vB_Template::create('showroster_userbits');
    
$templater->register('users'$users);
    
$templater->register('user'$user);
    
$templater->register('groupsort'$groupsort);
    
$templater->register('columns'$columns);
$rosterbits .= $templater->render(); 
The code is a little more indepth than that. $rosterbits goes to $rosterheader and that goes to $SHOWROSTER. The latter is the one that has print_output in case you were wondering.

Anyhow, here is the cool thing. groupsort is used to store the current title being sorted. In the template, if I use the following: {vb:var user.{vb:var groupsort}}, it works perfectly and gives the correct title of the current usergroup.

Also, using {vb:var columns.title1} and {vb:var columns.column1} work fine in the template.

Although, when I try to use {vb:var user.{vb:var columns.column1}}, the spot is blank. I've even replaced var with raw for testing, and it is still blank. I'm not sure what I missed, but I'm sure it is some beginner mistake. Either that, or array's can't be doubled up like a regular variable can be (i.e. {vb:var user.{vb:var groupsort}}).

I can provide the entire code if someone is interested and that is needed to figure out my problem. Thanks for your time.
Reply With Quote
  #2  
Old 02-11-2010, 08:02 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmmm, maybe {vb:var user.{$columns[column1]}}

Not really sure, but I'd play around with that.
Reply With Quote
  #3  
Old 02-11-2010, 08:43 PM
Sarcoth Sarcoth is offline
 
Join Date: Mar 2006
Location: Huntsville
Posts: 521
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne, thank you for giving me the inspiration of adding the brackets. I figured the brackets couldn't be used in the newer way, but this looks to have done the trick. I'll test it out more later and confirm.

{vb:var user.{vb:var columns[column6]}}
Reply With Quote
  #4  
Old 02-11-2010, 09:13 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh, that's an interesting way you ended up doing it! I would not have thought of that.
Reply With Quote
  #5  
Old 02-12-2010, 03:51 AM
Sarcoth Sarcoth is offline
 
Join Date: Mar 2006
Location: Huntsville
Posts: 521
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, I hope. For the record, I did try your way and other similiar ways. That one was the only one that worked though. Fun fun fun, I really enjoy learning this stuff.
Reply With Quote
Reply


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 09:42 PM.


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.05447 seconds
  • Memory Usage 2,215KB
  • Queries Executed 11 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (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_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
  • 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