vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Help with queries / eval() / templates (https://vborg.vbsupport.ru/showthread.php?t=82219)

Oreamnos 05-29-2005 11:26 PM

Help with queries / eval() / templates
 
I am writing some of my own pages and have a simple question regarding the interaction of the script and the templates.

i have this on test.php
PHP Code:

// Get some really valuable highly sought after information
$sql $DB_site->query("
    SELECT * FROM " 
TABLE_PREFIX "table_name"
);
    
while (
$row $DB_site->fetch_array($sql)) {

    eval(
'$not_sure_what_this_is .= "' fetch_template('MY_TEMPLATE') . '";');



and my template is basically
HTML Code:

<tr>
<td>$row[field1]</td>
<td>$row[field2]</td>
</tr>

so when the template is called the variables such as $row[field1] are printed to the page. But what is $not_sure_what_this_is? What does it do? Where can I use it? Is it necessary?

Thanks,
eric

Guest190829 05-29-2005 11:31 PM

Thats the variable you want to use for your template inside a "main" template....so for instance I would have a template called

hack_main

PHP Code:

<html>
<
body>
 <
table>
  <
tr>
   <
td>$hackbits</td>
  </
tr>
 </
table>
</
body>
</
html


then you would have another hack for named hack_bits...

hack_bits

PHP Code:

<tr>
<
td>$row[field1]</td>
<
td>$row[field2]</td>
</
tr

You would then use

eval('$hackbits .= "' . fetch_template('hack_bits') . '";');

To make it it show in the hack_main template...

So, when the script is finished the html would be parsed as...

<html>
<body>
<table>
<tr>
<td>

<tr>
<td>$row[field1]</td>
<td>$row[field2]</td>
</tr>

</td>
</tr>
</table>
</body>
</html>



sorry if this is confusing. I am still learning, so I hope im explaining it right..

Oreamnos 05-29-2005 11:39 PM

ok, that makes sense. i am totally missing the bits part. back to the admincp for me...

thanks
eric

Link14716 05-30-2005 01:09 AM

It's just a name.

The code used to parse the template
PHP Code:

eval('$not_sure_what_this_is .= "' fetch_template('MY_TEMPLATE') . '";'); 

does not print anything. It assigns the output to the $not_sure_what_this_is variable for future use. When the final template is called (which uses different code) it parses all the variables in it. Therefore, putting $not_sure_what_this_is in the final template or any template which comes after $not_sure_what_this_is is defined will make it appear where you put the variable.

Oreamnos 05-30-2005 01:10 AM

cool, thanks!


All times are GMT. The time now is 03:33 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.02244 seconds
  • Memory Usage 1,728KB
  • 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
  • (1)bbcode_html_printable
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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