Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 05-22-2007, 12:19 PM
byon byon is offline
 
Join Date: Apr 2007
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Foreach Loop & Templates

Hi

I've been reading around and looking for solution on how i can actually print out a full list of table information using the existing vBulletin infrastructure.

Today i've been successfully able to retrieve information from database in any *.php file then save as a variable $test, & print it out seperately with the variable on the template ($test).

but now ive got a problem where i need to print out an entire table of information, how can i go about doing this? please assist!
Reply With Quote
  #2  
Old 05-22-2007, 12:28 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hopefully this is all the advice you need. If you need more help reply and someone will get to this I'm sure.

PHP Code:
// Example array...
$array = array('first''second''third''fourth');

foreach (
$array AS $value)
{
    
// $value is the current array item we're looking at, make sure it's in the template below
    // Note the .= in the below, this means "append this at the end of '$var'" meaning data already in $var will not be overwritten
    
eval('$var .= "' fetch_template('your_custom_template') . '";');

Reply With Quote
  #3  
Old 05-22-2007, 12:32 PM
byon byon is offline
 
Join Date: Apr 2007
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Brad View Post
Hopefully this is all the advice you need. If you need more help reply and someone will get to this I'm sure.

PHP Code:
// Example array...
$array = array('first''second''third''fourth');

foreach (
$array AS $value)
{
    
// $value is the current array item we're looking at, make sure it's in the template below
    // Note the .= in the below, this means "append this at the end of '$var'" meaning data already in $var will not be overwritten
    
eval('$var .= "' fetch_template('your_custom_template') . '";');

Hi brad, this looks good. but this is going to result in templates in a template for my site. is this perfectly normal?
Reply With Quote
  #4  
Old 05-22-2007, 12:34 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by byon View Post
Hi brad, this looks good. but this is going to result in templates in a template for my site. is this perfectly normal?
Yes it's normal, vBulletin does it in many places.

When you need a template in a loop there is little else you can do.
Reply With Quote
  #5  
Old 05-22-2007, 12:40 PM
byon byon is offline
 
Join Date: Apr 2007
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Brad View Post
Yes it's normal, vBulletin does it in many places.

When you need a template in a loop there is little else you can do.
ah. now everything makes sense.
okay.

lemme work things out from here. you've been very helpful! how can i reeturn the favour?
Reply With Quote
  #6  
Old 05-22-2007, 12:45 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by byon View Post
ah. now everything makes sense.
okay.

lemme work things out from here. you've been very helpful! how can i reeturn the favour?
No need to return the favor!

But if you'd like...answer someone elses question if you know the answer.
Reply With Quote
Reply

Thread Tools
Display Modes

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 08:08 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02160 seconds
  • Memory Usage 2,214KB
  • 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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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_postinfo_query
  • fetch_postinfo
  • 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