vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Foreach Loop & Templates (https://vborg.vbsupport.ru/showthread.php?t=147849)

byon 05-22-2007 12:19 PM

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!

Brad 05-22-2007 12:28 PM

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') . '";');



byon 05-22-2007 12:32 PM

Quote:

Originally Posted by Brad (Post 1252656)
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?

Brad 05-22-2007 12:34 PM

Quote:

Originally Posted by byon (Post 1252657)
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. :)

byon 05-22-2007 12:40 PM

Quote:

Originally Posted by Brad (Post 1252659)
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?

Brad 05-22-2007 12:45 PM

Quote:

Originally Posted by byon (Post 1252662)
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. :)


All times are GMT. The time now is 07:09 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.02029 seconds
  • Memory Usage 1,733KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete