By: Mario Miele
Date: 2005-11-23
Time: 13:40
|
php file as templatehi,
May I use a PHP file instead of an HTML file as template? I always use almost the same structure for the web handling of mysql contents, so i'd like to write a PHP template (well, a text file with php code in it) to get a php program! Possible with TBS? Something particular I should know? |
|
By: Skrol29
Date: 2005-11-23
Time: 15:42
|
Re: php file as templateHow strange, but possible.
I see some requirements. You have to run the result of the merge using the eval() function, or to save it into a file and run it using inculde(), but this is a lost of execution time. If you want to run the result of the merge using eval(), then the template must not have "<?php" and "?>" tags. In order to catch the result of the merge, then you have to avoid the default behavior of the Show() method, which does output the result and the merge and exit the script. Example:
|
|
By: Mario Miele
Date: 2005-11-23
Time: 16:41
|
Re: php file as templatedear skrol29,
I don't want to directly execute the result of the merge, but to save it as a php file (copy and paste the result should be ok). In other words, i want to use TBS as a kind of code generator, calling it on my personal web server. |
|
By: Skrol29
Date: 2005-11-23
Time: 17:09
|
Re: php file as templateOk, so the principle is the same.
Instead of eval(), use:
|
|
By: Mario Miele
Date: 2005-11-23
Time: 17:29
|
ThanksThanks
|
|
By: Wil
Date: 2005-12-13
Time: 11:46
|
Re: php file as template>This for Php 5. Otherwise you have to use fopen() and fwrite().
OR use "PHP_Compat" http://us3.php.net/manual/en/function.file-put-contents.php#42551 http://pear.php.net/package/PHP_Compat |