vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Calling a template in a while (https://vborg.vbsupport.ru/showthread.php?t=181165)

The-Ensemble 06-01-2008 01:11 AM

Calling a template in a while
 
I'd of written a more descriptive title if I knew what was wrong.

I'm trying to list information from a table and to do it I first printed a template then underneath that in the plugin I wrote.

PHP Code:

while ($category mysql_fetch_assoc($result)) {

$categoryname $category['name'];
$catid $category['id'];
$catdesc $category['description'];

eval(
'$cats .= "' fetch_template('extra_categoriesbit') . '";');



And it returns blank, I know its not the database or the while thats the problem, because before I did it echo'ing the html and the variables and it worked fine.

I added eval for the template, and put $cats in the first printed template for where I wanted these results to go and they don't show up and I don't get why. Its probably something stupid I'm overlooking.

Any ideas?

EDIT--Oh and I know its not the template name, I've checked that around 4 times now.

mikesz 06-01-2008 01:20 AM

Where is your query?

The-Ensemble 06-01-2008 01:29 AM

Its above.

Heres the whole plugin

PHP Code:

if ($_REQUEST['do'] == 'catlist')
{
$result mysql_query("SELECT * FROM `vb_extra_cats` ORDER BY `displayorder`;");

eval(
'print_output("' fetch_template('extra_categories') . '");');

while (
$category mysql_fetch_assoc($result)) {

$categoryname $category["name"];
$catid $category['id'];
$catdesc $category['description'];

eval(
'$cats .= "' fetch_template('extra_categoriesbit') . '";');

}





MoT3rror 06-01-2008 03:00 AM

How are you outputting $cats? echo? Using it in a template that is further down the code using print_output function? Your current code is outputting nothing.

The-Ensemble 06-01-2008 04:45 AM

I'm outputting it through the extra_categories template using $cats to compile the list.

MoT3rror 06-01-2008 05:46 AM

Try moving this after the while
PHP Code:

eval('print_output("' fetch_template('extra_categories') . '");'); 


The-Ensemble 06-01-2008 06:25 AM

Quote:

Originally Posted by MoT3rror (Post 1537588)
Try moving this after the while
PHP Code:

eval('print_output("' fetch_template('extra_categories') . '");'); 


Hey that worked, thanks!

Opserty 06-01-2008 08:55 AM

print_output() end the script execution, hence nothing after that line will be run. :)


All times are GMT. The time now is 04:19 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.01068 seconds
  • Memory Usage 1,735KB
  • 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
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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