News:

Wondering if this will always be free?  See why free is better.

Main Menu

Template System question

Started by Rudolf, January 13, 2006, 04:52:36 AM

Previous topic - Next topic

Rudolf

  Looking at the code I noticed that the template and language files are actually inserted before the data is being pulled out from the database and processed.

  I figured it out by now, that the templates work with the context array to show up the data.
  But how, if when those files are included the context array is empty?

  It is something that just excapes my logic. I looked at the LoadLanguage and LoadTemplate functions, but still can't understand how is possible. Some PHP trick, the way files are included?
  I would be eternally greatful if someone explains this to me.

Rudolf
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

Dannii

The templates are selected and loaded before the sourcefile is run, however they wait till after the source is finished to display anything. I'm not sure exactly how that is done, however it probably has something to do with the templates being evaluated instead of just run.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Rudolf

Well, this is what I said myself too.
After a little digging maybe I found the answer, though the details I still don't fully understand.
I'm almost sure that it's done using the output buffering.
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

sQuarecoW

I'm looking for the same thing/answers.. Is there anyone who can explain me some basics on how SMF passes all this around?

Dannii

The basics of how SMF works is that index.php finds out what action to run. It then loads the corresponding source file, which will put everything relevant into the $context array. The source file will load the corresponding template file, which will output everything it wants to from the $context array.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

sQuarecoW

tnx! That's a clear and simple explanation!

But.. i've been reading through the code for some ours, nut I still can't find when de above and below template is called, and what takes care of putting it all in the right place and the right order on the screen....

Rudolf

the obExit function in the Subs.php
that's the one that actually loads the template or subtemplate
at least so it seems
It's a little bit twisted

Quote from: eldacar on February 12, 2006, 06:04:54 AM
The source file will load the corresponding template file, which will output everything it wants to from the $context array.
Actually in every source file the template files are loaded before the relevant values are put into the $context array. The template gets "loaded" in the obExit function.

The above and below templates are even more twisted. They are included in the template_header and template_footer functions in the Subs.php. These two are called within the obExit.

Rudolf
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

Advertisement: