Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 12-26-2002, 05:33 PM
tHE DSS's Avatar
tHE DSS tHE DSS is offline
 
Join Date: Jun 2002
Location: UK
Posts: 113
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The template system is a powerful dynamic/expandable type system. It's main power comes from the 'eval()'.

Say you have a little template titled "twoPlusTwo", and it contained :

Code:
<table cellpadding="0" cellspacing="0" border="0">
	<td align="left" valign="center">2 + 2 = $calc_result</td>
</table>
... to get that ready for output, you would call that template in via the 'gettemplate()' function, like this :

PHP Code:
$calc_result 2;
eval(
"\$twoPlusTwo = \"".gettemplate('twoPlusTwo')."\";"); 
... as we are 'evaluating' the function and return data here as a 'string' variable, your '$calc_result' value is 'expanded' by PHP.

The 'gettemplate()' function returns the contents of 'twoPlusTwo', into the string type variable we've named 'twoPlusTwo', at the start of the 'eval()'.

You notice the contents of the template has the bit '$calc_result'.... well, because you've put a value into that variable name, the getting the template in this way, puts your value into the template (your value gets expanded, and your dynamic string is created).

It's just like doing this :

PHP Code:
$calc_result 2;
echo 
"2 + 2 = $calc_result"
... except, the template system gives much much more scope for outputting complete pages, and for re-organising your pages.

With this system, you use the gettemplate() function to retrieve all your little bits of the webpage - they are smaller chunks for easier managment, and for giving you more scope.

Once you've retrieved all of your templates into string variables, and the data inside has been expanded, you are then ready for output.

This is where you need an over-all page layout template. Like this, called 'testPage', for example :

Code:
<html>
<head>
	<title>Test</title>
</head>
<body bgcolor="#ffffff" text="#000000">
This is our example of how the vB template system works.
<p>
$twoPlusTwo
</html>
... notice that you have the $twoPlusTwo variable (contiaining your previously generated template) named inside the main page display template, just like we did above, when using the result of the little calculation.

What you then do, once all your page templates are generated in the above way, is make a call to the 'dooutput()' function, like this :

PHP Code:
eval("dooutput(\"".gettemplate('testPage')."\");"); 
... same deal here. We get the template 'testPage', which contains our page layout and $twoPlusTwo variable, which contains the now fully expanded 'twoPlusTwo template, and we send that to the dooutput() function.

As you now have all your dynamically created templates inside the computer memory, all your variables get expanded in the dooutput() function, and then the dooutput() function simply uses the "echo" to echo the whole job lot out to the browser.

It's very powerful, very simple, very very good.

I'm not a great teacher... so hopfully i've helped. aranoid:

That's how the system works anyway, and you can use it in any way you see fit.
Reply With Quote
 


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 10:10 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.04983 seconds
  • Memory Usage 2,488KB
  • Queries Executed 12 (?)
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
  • (3)bbcode_code
  • (7)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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