smarty] Re: How does compiling work?
| From: | Brian E . Lozier | Date: | Fri, 28 Dec 2001 22:51:13 +0000 |
| Subject: | smarty] Re: How does compiling work? | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-2425@lists.php.net to get a copy of this message | ||
Then what exactly does compiling do? It compiles the templates themselves together? But what
happens if I
have a conditional template call?
if($condition) {
$tpl->assign('Content', $tpl->fetch('condition1.tpl'));
} else {
$tpl->assign('Content', $tpl->fetch('condition2.tpl'));
}
How does smarty compile that? If it leaves the templates totally separate (which seems like the
only way
possible..) why is it called compiling? What gets compiled?
----- Original Message -----
From: Andrei Zmievski <andrei@ispi.net>
To: smarty@lists.ispi.net
Date: 12/28/01 2:16:10 PM
>
>On Fri, 28 Dec 2001, Brian E. Lozier wrote:
>> How can a compiled system such as this work? Is it doing all my database calls twice? Is
>> it rebuilding
the
>> compiled template on each invocation of the script?
>>
>> If I've got an index.php which contains something like:
>>
>> $tpl = new Smarty;
>>
>> $dbInfo = mysql_fetch_row();
>> $tpl->assign('DBInfo', $dbInfo);
>>
>> $tpl->display('main.tpl');
>>
>> It doesn't seem like it has a chance to just use the compiled template BEFORE
>> executing all the logic in
the
>> main script. So the question is, is it doing all the db calls first, then seeing the
>> compiled 'main.tpl',
>> deciding it doesn't need recompiling, then it's re-doing all the db calls in the
>> compiled version,
ignoring
>> everything that happened previously?
>
>Compiled templates don't have any DB calls. Your main scripts has them.
>
>-Andrei
>
>"In My Egotistical Opinion, most people's C programs should be indented
>six feet downward and covered with dirt." -- Blair P. Houghton
>
>---
>You are currently subscribed to smarty as: brian@massassi.net
>To unsubscribe send a blank email to $subst('Email.Unsub')
>Visit Smarty's homepage at
>http://www.phpinsider.com/php/code/Smarty/